codeplay-common 4.3.6 → 4.3.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.
- package/.gitattributes +2 -2
- package/LICENSE +21 -21
- package/README.md +125 -125
- package/files/buildCodeplay/codeplayBeforeBuild-6.2.js +4107 -4107
- package/files/buildCodeplay/versions.json +23 -23
- package/files/finalrelease +51 -12
- package/files/iap-install-2.js +145 -145
- package/files/ionic.config.json +6 -6
- package/files/scripts/setup-baseline-profile.js +262 -262
- package/files/take-screen-image.js +1228 -1228
- package/files/take-screen-video.js +23 -21
- package/package.json +15 -15
- package/scripts/sync-files.js +103 -103
- package/scripts/uninstall.js +109 -109
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
{
|
|
2
|
-
"plugins":[
|
|
3
|
-
{"name":"backbutton","pattern":"backbutton-(\\d+\\.\\d+)\\.js$","minVersion":"2.1","baseDir":"js","mandatoryUpdate":true},
|
|
1
|
+
{
|
|
2
|
+
"plugins":[
|
|
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.7","baseDir":"js","mandatoryUpdate":true},
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
{"name":"admob-emi-nextgen","pattern":"Ads[\\\\/]admob-emi-nextgen-(\\d+\\.\\d+)\\.js$","minVersion":"1.0","baseDir":"js","mandatoryUpdate":true},
|
|
7
|
-
{"name":"video-player","pattern":"video-player-(\\d+\\.\\d+)\\.js$","minVersion":"1.6","baseDir":"js","mandatoryUpdate":true},
|
|
8
|
-
{"name":"image-cropper","pattern":"image-cropper-(\\d+\\.\\d+)\\.js$","minVersion":"1.1","baseDir":"js","mandatoryUpdate":true},
|
|
9
|
-
{"name":"beautify","pattern":"beautify-(\\d+\\.\\d+)\\.js$","minVersion":"1.1","baseDir":"js","mandatoryUpdate":true},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{"name":"localization","pattern":"localization-(\\d+\\.\\d+)$","minVersion":"1.8","baseDir":"js/localization","mandatoryUpdate":true,"isFolder":true},
|
|
13
|
-
{"name": "localization_settings","pattern": "localization_settings-(\\d+\\.\\d+)\\.js$","minVersion": "1.1","required": true,"baseDir": "js/localization","mandatoryUpdate": true},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{"name":"editor","pattern":"editor-(\\d+\\.\\d+)$","minVersion":"2.0","baseDir":"js/editor","mandatoryUpdate":true,"isFolder":true},
|
|
17
|
-
{"name":"ffmpeg","pattern":"ffmpeg-(\\d+\\.\\d+)$","minVersion":"1.6","baseDir":"js","mandatoryUpdate":true,"isFolder":true},
|
|
18
|
-
{"name":"theme","pattern":"theme-(\\d+\\.\\d+)$","minVersion":"3.5","baseDir":"theme","destDir":"theme","mandatoryUpdate":true,"isFolder":true},
|
|
19
|
-
{"name":"certificatejs","pattern":"certificatejs-(\\d+\\.\\d+)$","minVersion":"1.9","baseDir":"certificate","destDir":"certificate","mandatoryUpdate":true,"isFolder":true},
|
|
7
|
+
{"name":"video-player","pattern":"video-player-(\\d+\\.\\d+)\\.js$","minVersion":"1.6","baseDir":"js","mandatoryUpdate":true},
|
|
8
|
+
{"name":"image-cropper","pattern":"image-cropper-(\\d+\\.\\d+)\\.js$","minVersion":"1.1","baseDir":"js","mandatoryUpdate":true},
|
|
9
|
+
{"name":"beautify","pattern":"beautify-(\\d+\\.\\d+)\\.js$","minVersion":"1.1","baseDir":"js","mandatoryUpdate":true},
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
{"name":"localization","pattern":"localization-(\\d+\\.\\d+)$","minVersion":"1.8","baseDir":"js/localization","mandatoryUpdate":true,"isFolder":true},
|
|
13
|
+
{"name": "localization_settings","pattern": "localization_settings-(\\d+\\.\\d+)\\.js$","minVersion": "1.1","required": true,"baseDir": "js/localization","mandatoryUpdate": true},
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
{"name":"editor","pattern":"editor-(\\d+\\.\\d+)$","minVersion":"2.0","baseDir":"js/editor","mandatoryUpdate":true,"isFolder":true},
|
|
17
|
+
{"name":"ffmpeg","pattern":"ffmpeg-(\\d+\\.\\d+)$","minVersion":"1.6","baseDir":"js","mandatoryUpdate":true,"isFolder":true},
|
|
18
|
+
{"name":"theme","pattern":"theme-(\\d+\\.\\d+)$","minVersion":"3.5","baseDir":"theme","destDir":"theme","mandatoryUpdate":true,"isFolder":true},
|
|
19
|
+
{"name":"certificatejs","pattern":"certificatejs-(\\d+\\.\\d+)$","minVersion":"1.9","baseDir":"certificate","destDir":"certificate","mandatoryUpdate":true,"isFolder":true},
|
|
20
20
|
{"name":"IAP","pattern":"IAP-(\\d+\\.\\d+)$","minVersion":"3.6","baseDir":"js/Ads","mandatoryUpdate":true,"isFolder":true},
|
|
21
|
-
{"name":"common-less","pattern":"common-(\\d+\\.\\d+)\\.less$","minVersion":"1.8","baseDir":"assets/css","mandatoryUpdate":true},
|
|
22
|
-
{"name":"localNotification_AppSettings","pattern":"localNotification_AppSettings-(\\d+\\.\\d+)\\.js$","minVersion":"1.0","baseDir":"js","mandatoryUpdate":true},
|
|
23
|
-
{"name":"localNotification","pattern":"localNotification-(\\d+\\.\\d+)\\.js$","minVersion":"2.2","baseDir":"js","mandatoryUpdate":true},
|
|
24
|
-
{"name":"onesignal","pattern":"onesignal-(\\d+\\.\\d+)\\.js$","minVersion":"2.4","baseDir":"js","mandatoryUpdate":true},
|
|
25
|
-
{"name":"saveToGalleryAndSaveAnyFile","pattern":"saveToGalleryAndSaveAnyFile-(\\d+\\.\\d+)(-ios)?\\.js$","minVersion":"3.1","baseDir":"js","mandatoryUpdate":true}
|
|
26
|
-
]
|
|
21
|
+
{"name":"common-less","pattern":"common-(\\d+\\.\\d+)\\.less$","minVersion":"1.8","baseDir":"assets/css","mandatoryUpdate":true},
|
|
22
|
+
{"name":"localNotification_AppSettings","pattern":"localNotification_AppSettings-(\\d+\\.\\d+)\\.js$","minVersion":"1.0","baseDir":"js","mandatoryUpdate":true},
|
|
23
|
+
{"name":"localNotification","pattern":"localNotification-(\\d+\\.\\d+)\\.js$","minVersion":"2.2","baseDir":"js","mandatoryUpdate":true},
|
|
24
|
+
{"name":"onesignal","pattern":"onesignal-(\\d+\\.\\d+)\\.js$","minVersion":"2.4","baseDir":"js","mandatoryUpdate":true},
|
|
25
|
+
{"name":"saveToGalleryAndSaveAnyFile","pattern":"saveToGalleryAndSaveAnyFile-(\\d+\\.\\d+)(-ios)?\\.js$","minVersion":"3.1","baseDir":"js","mandatoryUpdate":true}
|
|
26
|
+
]
|
|
27
27
|
}
|
package/files/finalrelease
CHANGED
|
@@ -275,14 +275,14 @@ const checkIsAdsDisableByReturnStatement=()=>{
|
|
|
275
275
|
|
|
276
276
|
|
|
277
277
|
const adsFolder = join('src', 'js', 'Ads');
|
|
278
|
-
const filePattern = /^admob-emi-nextgen-(\d+\.)+\d+\.js$/;
|
|
278
|
+
const filePattern = /^admob-emi-nextgen-(\d+\.)+\d+\.js$/;
|
|
279
279
|
|
|
280
280
|
// Step 1: Find the admob file
|
|
281
281
|
const files = readdirSync(adsFolder);
|
|
282
282
|
const admobFile = files.find(f => filePattern.test(f));
|
|
283
283
|
|
|
284
284
|
if (!admobFile) {
|
|
285
|
-
console.log('❌ No Admob nextgen file found.');
|
|
285
|
+
console.log('❌ No Admob nextgen file found.');
|
|
286
286
|
process.exit(1);
|
|
287
287
|
}
|
|
288
288
|
|
|
@@ -527,8 +527,30 @@ if (existsSync(aabOutputDir)) {
|
|
|
527
527
|
|
|
528
528
|
|
|
529
529
|
// Extract version code and version name from build.gradle
|
|
530
|
-
const gradleFilePath = join("android", "app", "build.gradle");
|
|
531
|
-
const gradleContent = readFileSync(gradleFilePath, 'utf8');
|
|
530
|
+
const gradleFilePath = join("android", "app", "build.gradle");
|
|
531
|
+
const gradleContent = readFileSync(gradleFilePath, 'utf8');
|
|
532
|
+
|
|
533
|
+
// Return the character range of a Gradle block, allowing nested blocks inside it.
|
|
534
|
+
function findGradleBlock(content, headerPattern) {
|
|
535
|
+
const headerMatch = content.match(headerPattern);
|
|
536
|
+
if (!headerMatch) return null;
|
|
537
|
+
const openingBrace = content.indexOf('{', headerMatch.index + headerMatch[0].length);
|
|
538
|
+
if (openingBrace === -1) return null;
|
|
539
|
+
let depth = 0;
|
|
540
|
+
let quote = null;
|
|
541
|
+
for (let index = openingBrace; index < content.length; index += 1) {
|
|
542
|
+
const character = content[index];
|
|
543
|
+
const previous = content[index - 1];
|
|
544
|
+
if (quote) {
|
|
545
|
+
if (character === quote && previous !== '\\') quote = null;
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
if (character === '\"' || character === "'") quote = character;
|
|
549
|
+
else if (character === '{') depth += 1;
|
|
550
|
+
else if (character === '}' && --depth === 0) return { start: openingBrace + 1, end: index };
|
|
551
|
+
}
|
|
552
|
+
return null;
|
|
553
|
+
}
|
|
532
554
|
|
|
533
555
|
const versionCodeMatch = gradleContent.match(/versionCode\s+(\d+)/);
|
|
534
556
|
const versionNameMatch = gradleContent.match(/versionName\s+"([^"]+)"/);
|
|
@@ -595,9 +617,26 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
|
|
|
595
617
|
`$1\n minifyEnabled ${desiredMinify}`
|
|
596
618
|
);
|
|
597
619
|
console.log(`✅ Inserted minifyEnabled ${desiredMinify} into release block.`);
|
|
598
|
-
} else {
|
|
599
|
-
console.log('⚠️ Warning: buildTypes > release block not found. minifyEnabled was not added.');
|
|
600
|
-
}
|
|
620
|
+
} else {
|
|
621
|
+
console.log('⚠️ Warning: buildTypes > release block not found. minifyEnabled was not added.');
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// Add native debug symbols for release AABs, but leave any existing setting untouched.
|
|
625
|
+
const releaseBlock = findGradleBlock(updatedGradleContent, /buildTypes\s*\{[\s\S]*?\brelease\s*/);
|
|
626
|
+
if (releaseBlock) {
|
|
627
|
+
const releaseContent = updatedGradleContent.slice(releaseBlock.start, releaseBlock.end);
|
|
628
|
+
if (/\bdebugSymbolLevel\b/.test(releaseContent)) {
|
|
629
|
+
console.log('ℹ️ debugSymbolLevel already exists in buildTypes.release; leaving it unchanged.');
|
|
630
|
+
} else {
|
|
631
|
+
const ndkBlock = `\n ndk {\n debugSymbolLevel 'FULL'\n }`;
|
|
632
|
+
updatedGradleContent = updatedGradleContent.slice(0, releaseBlock.end)
|
|
633
|
+
+ ndkBlock
|
|
634
|
+
+ updatedGradleContent.slice(releaseBlock.end);
|
|
635
|
+
console.log("✅ Added debugSymbolLevel 'FULL' to buildTypes.release.");
|
|
636
|
+
}
|
|
637
|
+
} else {
|
|
638
|
+
console.log('⚠️ Warning: buildTypes.release block not found. debugSymbolLevel was not added.');
|
|
639
|
+
}
|
|
601
640
|
|
|
602
641
|
|
|
603
642
|
|
|
@@ -714,11 +753,11 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
|
|
|
714
753
|
|
|
715
754
|
|
|
716
755
|
// Copy the built files to the appropriate folder
|
|
717
|
-
const src = join("www");
|
|
718
|
-
const dest = join("android", "app", "src", "main", "assets", "public");
|
|
719
|
-
|
|
720
|
-
// Copy the web build with Node so releases work on every platform.
|
|
721
|
-
fs.cpSync(src, dest, { recursive: true, force: true });
|
|
756
|
+
const src = join("www");
|
|
757
|
+
const dest = join("android", "app", "src", "main", "assets", "public");
|
|
758
|
+
|
|
759
|
+
// Copy the web build with Node so releases work on every platform.
|
|
760
|
+
fs.cpSync(src, dest, { recursive: true, force: true });
|
|
722
761
|
|
|
723
762
|
// Build Android AAB file
|
|
724
763
|
//child_process.execSync('cd android && ./gradlew bundleRelease', { stdio: 'inherit' });
|
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
|
}
|