codeplay-common 1.9.1 → 1.9.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.
package/.gitattributes CHANGED
@@ -1,2 +1,2 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Merbin Joe
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Merbin Joe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # codeplay-common
2
- Everything automatted in Capacitor apps, easy to maintain many apps in capacitor. It will reduce your 40% of work, with common file code.
3
-
4
-
5
- Easy add splashscreen and set animation
6
- Admob id automatically from capacitor.config.json file
7
- Make three build file for different store as per our requirement
8
- Based on store install various IAP plugins
9
- Make it to ionic project
10
-
11
- Donate to get full code including many common functions
1
+ # codeplay-common
2
+ Everything automatted in Capacitor apps, easy to maintain many apps in capacitor. It will reduce your 40% of work, with common file code.
3
+
4
+
5
+ Easy add splashscreen and set animation
6
+ Admob id automatically from capacitor.config.json file
7
+ Make three build file for different store as per our requirement
8
+ Based on store install various IAP plugins
9
+ Make it to ionic project
10
+
11
+ Donate to get full code including many common functions
12
12
  https://ko-fi.com/codeplay
@@ -1,226 +1,248 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const { isStringObject } = require("util/types");
4
-
5
- const configPath = path.join(process.cwd(), 'capacitor.config.json');
6
-
7
- // Define file paths
8
- const projectFolder = path.resolve(".");
9
- const sourceSplashIcon = path.join(projectFolder, "resources", "splash_icon.png");
10
- const destinationSplashIcon = path.join(
11
- projectFolder,
12
- "android",
13
- "app",
14
- "src",
15
- "main",
16
- "res",
17
- "drawable-nodpi",
18
- "splash_icon.png"
19
- );
20
-
21
-
22
-
23
-
24
-
25
- const sourceSplashXML = path.join(projectFolder,"buildCodeplay", "splashxml", "codeplay_splashScreen.xml");
26
- const destinationSplashXML = path.join(
27
- projectFolder,
28
- "android",
29
- "app",
30
- "src",
31
- "main",
32
- "res",
33
- "values",
34
- "codeplay_splashScreen.xml"
35
- );
36
- const androidManifestPath = path.join(
37
- projectFolder,
38
- "android",
39
- "app",
40
- "src",
41
- "main",
42
- "AndroidManifest.xml"
43
- );
44
-
45
- // Helper function to copy files
46
- function copyFile(source, destination) {
47
- if (!fs.existsSync(source)) {
48
- throw new Error(`Source file not found: ${source}`);
49
- }
50
- fs.mkdirSync(path.dirname(destination), { recursive: true });
51
- fs.copyFileSync(source, destination);
52
- console.log(`Copied: ${source} -> ${destination}`);
53
- }
54
-
55
- // Helper function to update AndroidManifest.xml
56
- function updateAndroidManifest() {
57
- if (!fs.existsSync(androidManifestPath)) {
58
- throw new Error(`AndroidManifest.xml not found: ${androidManifestPath}`);
59
- }
60
-
61
-
62
-
63
-
64
-
65
- const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
66
-
67
-
68
- let logErrorMessage="";
69
-
70
- const RESIZEABLE_ACTIVITY = config.android?.RESIZEABLE_ACTIVITY;
71
- const orientation = config.android?.ORIENTATION;
72
-
73
- // 1️⃣ Check if it’s missing
74
- if (RESIZEABLE_ACTIVITY === undefined) {
75
- logErrorMessage+='❌ Missing android.RESIZEABLE_ACTIVITY option in capacitor.config.json.\n';
76
- }
77
-
78
- // 2️⃣ Check if it’s not boolean (true/false only)
79
- else if (typeof RESIZEABLE_ACTIVITY !== 'boolean') {
80
- logErrorMessage+='❌ Invalid android.RESIZEABLE_ACTIVITY value. Please use only true or false (without quotes).\n';
81
- }
82
-
83
-
84
-
85
- if (!orientation) {
86
- logErrorMessage+='❌ Missing android.ORIENTATION option in capacitor.config.json.\n';
87
- }
88
-
89
- else if(orientation!="portrait" && orientation!="landscape" && orientation!="auto")
90
- {
91
- logErrorMessage+='❌ Spelling mistake in android.ORIENTATION option in capacitor.config.json. Please use only ["portrait" "landscape" "auto"]\n';
92
- }
93
-
94
- if(logErrorMessage!="")
95
- {
96
- console.error(logErrorMessage);
97
- process.exit(1)
98
- }
99
-
100
-
101
- let manifestContent = fs.readFileSync(androidManifestPath, "utf-8");
102
-
103
- manifestContent = manifestContent.replace(
104
- /<activity[^>]*?>/,
105
- (match) => {
106
- let updated = match;
107
-
108
- // If android:theme is already present, update it
109
- if (updated.includes('android:theme=')) {
110
- updated = updated.replace(
111
- /android:theme="[^"]*"/,
112
- 'android:theme="@style/Theme.Codeplay.SplashScreen"'
113
- );
114
- }
115
-
116
- // If android:resizeableActivity is already present, update it
117
- if (updated.includes('android:resizeableActivity=')) {
118
- updated = updated.replace(
119
- /android:resizeableActivity="[^"]*"/,
120
- `android:resizeableActivity="${RESIZEABLE_ACTIVITY}"`
121
- );
122
- } else {
123
- // Add resizeableActivity attribute
124
- updated = updated.replace(`<activity`, `<activity android:resizeableActivity="${RESIZEABLE_ACTIVITY}"`);
125
- }
126
-
127
-
128
- //const admobConfig = getAdMobConfig();
129
-
130
-
131
-
132
-
133
-
134
- if(orientation=="portrait"){
135
- // If android:screenOrientation is already present, update it
136
- if (updated.includes('android:screenOrientation=')) {
137
- updated = updated.replace(
138
- /android:screenOrientation="[^"]*"/,
139
- 'android:screenOrientation="portrait"'
140
- );
141
- } else {
142
- updated = updated.replace(
143
- '<activity',
144
- '<activity android:screenOrientation="portrait"'
145
- );
146
- }
147
- }
148
-
149
-
150
-
151
- if(orientation=="landscape"){
152
- // If android:screenOrientation is already present, update it
153
- if (updated.includes('android:screenOrientation=')) {
154
- updated = updated.replace(
155
- /android:screenOrientation="[^"]*"/,
156
- 'android:screenOrientation="landscape"'
157
- );
158
- } else {
159
- updated = updated.replace(
160
- '<activity',
161
- '<activity android:screenOrientation="landscape"'
162
- );
163
- }
164
- }
165
-
166
-
167
- if (orientation === "auto") {
168
- // Remove android:screenOrientation attribute if present
169
- updated = updated.replace(/\s*android:screenOrientation="[^"]*"/, '');
170
- }
171
-
172
-
173
-
174
- return updated;
175
- }
176
- );
177
-
178
- fs.writeFileSync(androidManifestPath, manifestContent, "utf-8");
179
- console.log(`Updated AndroidManifest.xml: ensured resizeableActivity="false" and updated theme if present.`);
180
- }
181
-
182
-
183
- function removeOldSplashImages() {
184
- const drawableFolders = [
185
- "drawable",
186
- "drawable-land-hdpi",
187
- "drawable-land-mdpi",
188
- "drawable-land-xhdpi",
189
- "drawable-land-xxhdpi",
190
- "drawable-land-xxxhdpi",
191
- "drawable-port-hdpi",
192
- "drawable-port-mdpi",
193
- "drawable-port-xhdpi",
194
- "drawable-port-xxhdpi",
195
- "drawable-port-xxxhdpi"
196
- ];
197
-
198
- drawableFolders.forEach((folder) => {
199
- const filePath = path.join(projectFolder, "android", "app", "src", "main", "res", folder, "splash.png");
200
- if (fs.existsSync(filePath)) {
201
- fs.unlinkSync(filePath);
202
- console.log(`Removed: ${filePath}`);
203
- } else {
204
- console.log(`Not found (skipped): ${filePath}`);
205
- }
206
- });
207
- }
208
-
209
- // Perform the tasks
210
- try {
211
- console.log("Starting splash screen setup...");
212
- copyFile(sourceSplashIcon, destinationSplashIcon);
213
- copyFile(sourceSplashXML, destinationSplashXML);
214
- updateAndroidManifest();
215
- console.log("Splash screen setup completed.");
216
-
217
- console.log("Removing default splash.png files...");
218
- removeOldSplashImages()
219
-
220
- } catch (error) {
221
- console.error(`Error: ${error.message}`);
222
- process.exit(1);
223
- }
224
-
225
-
226
-
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const { isStringObject } = require("util/types");
4
+
5
+ const configPath = path.join(process.cwd(), 'capacitor.config.json');
6
+
7
+ // Define file paths
8
+ const projectFolder = path.resolve(".");
9
+ const sourceSplashIcon = path.join(projectFolder, "resources", "splash_icon.png");
10
+ const destinationSplashIcon = path.join(
11
+ projectFolder,
12
+ "android",
13
+ "app",
14
+ "src",
15
+ "main",
16
+ "res",
17
+ "drawable-nodpi",
18
+ "splash_icon.png"
19
+ );
20
+
21
+
22
+
23
+
24
+
25
+ const sourceSplashXML = path.join(projectFolder,"buildCodeplay", "splashxml", "codeplay_splashScreen.xml");
26
+ const destinationSplashXML = path.join(
27
+ projectFolder,
28
+ "android",
29
+ "app",
30
+ "src",
31
+ "main",
32
+ "res",
33
+ "values",
34
+ "codeplay_splashScreen.xml"
35
+ );
36
+ const androidManifestPath = path.join(
37
+ projectFolder,
38
+ "android",
39
+ "app",
40
+ "src",
41
+ "main",
42
+ "AndroidManifest.xml"
43
+ );
44
+
45
+ // Helper function to copy files
46
+ function copyFile(source, destination) {
47
+ if (!fs.existsSync(source)) {
48
+ throw new Error(`Source file not found: ${source}`);
49
+ }
50
+ fs.mkdirSync(path.dirname(destination), { recursive: true });
51
+ fs.copyFileSync(source, destination);
52
+ console.log(`Copied: ${source} -> ${destination}`);
53
+ }
54
+
55
+ // Helper function to update AndroidManifest.xml
56
+ function updateAndroidManifest() {
57
+ if (!fs.existsSync(androidManifestPath)) {
58
+ throw new Error(`AndroidManifest.xml not found: ${androidManifestPath}`);
59
+ }
60
+
61
+
62
+
63
+
64
+
65
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
66
+
67
+
68
+ let logErrorMessage="";
69
+
70
+ const RESIZEABLE_ACTIVITY = config.android?.RESIZEABLE_ACTIVITY;
71
+ const orientation = config.android?.ORIENTATION;
72
+
73
+ // 1️⃣ Check if it’s missing
74
+ if (RESIZEABLE_ACTIVITY === undefined) {
75
+ logErrorMessage+='❌ Missing android.RESIZEABLE_ACTIVITY option in capacitor.config.json.\n';
76
+ }
77
+
78
+ // 2️⃣ Check if it’s not boolean (true/false only)
79
+ else if (typeof RESIZEABLE_ACTIVITY !== 'boolean') {
80
+ logErrorMessage+='❌ Invalid android.RESIZEABLE_ACTIVITY value. Please use only true or false (without quotes).\n';
81
+ }
82
+
83
+
84
+
85
+ if (!orientation) {
86
+ logErrorMessage+='❌ Missing android.ORIENTATION option in capacitor.config.json.\n';
87
+ }
88
+
89
+ else if(orientation!="portrait" && orientation!="landscape" && orientation!="auto")
90
+ {
91
+ logErrorMessage+='❌ Spelling mistake in android.ORIENTATION option in capacitor.config.json. Please use only ["portrait" "landscape" "auto"]\n';
92
+ }
93
+
94
+ if(logErrorMessage!="")
95
+ {
96
+ console.error(logErrorMessage);
97
+ process.exit(1)
98
+ }
99
+
100
+
101
+ let manifestContent = fs.readFileSync(androidManifestPath, "utf-8");
102
+
103
+ manifestContent = manifestContent.replace(
104
+ /<activity[^>]*?>/,
105
+ (match) => {
106
+ let updated = match;
107
+
108
+ // If android:theme is already present, update it
109
+ if (updated.includes('android:theme=')) {
110
+ updated = updated.replace(
111
+ /android:theme="[^"]*"/,
112
+ 'android:theme="@style/Theme.Codeplay.SplashScreen"'
113
+ );
114
+ }
115
+
116
+ // If android:resizeableActivity is already present, update it
117
+ if (updated.includes('android:resizeableActivity=')) {
118
+ updated = updated.replace(
119
+ /android:resizeableActivity="[^"]*"/,
120
+ `android:resizeableActivity="${RESIZEABLE_ACTIVITY}"`
121
+ );
122
+ } else {
123
+ // Add resizeableActivity attribute
124
+ updated = updated.replace(`<activity`, `<activity android:resizeableActivity="${RESIZEABLE_ACTIVITY}"`);
125
+ }
126
+
127
+
128
+ //const admobConfig = getAdMobConfig();
129
+
130
+
131
+
132
+
133
+
134
+ if(orientation=="portrait"){
135
+ // If android:screenOrientation is already present, update it
136
+ if (updated.includes('android:screenOrientation=')) {
137
+ updated = updated.replace(
138
+ /android:screenOrientation="[^"]*"/,
139
+ 'android:screenOrientation="portrait"'
140
+ );
141
+ } else {
142
+ updated = updated.replace(
143
+ '<activity',
144
+ '<activity android:screenOrientation="portrait"'
145
+ );
146
+ }
147
+ }
148
+
149
+
150
+
151
+ if(orientation=="landscape"){
152
+ // If android:screenOrientation is already present, update it
153
+ if (updated.includes('android:screenOrientation=')) {
154
+ updated = updated.replace(
155
+ /android:screenOrientation="[^"]*"/,
156
+ 'android:screenOrientation="landscape"'
157
+ );
158
+ } else {
159
+ updated = updated.replace(
160
+ '<activity',
161
+ '<activity android:screenOrientation="landscape"'
162
+ );
163
+ }
164
+ }
165
+
166
+
167
+ if (orientation === "auto") {
168
+ // Remove android:screenOrientation attribute if present
169
+ updated = updated.replace(/\s*android:screenOrientation="[^"]*"/, '');
170
+ }
171
+
172
+
173
+
174
+ return updated;
175
+ }
176
+ );
177
+
178
+ fs.writeFileSync(androidManifestPath, manifestContent, "utf-8");
179
+ console.log(`Updated AndroidManifest.xml: ensured resizeableActivity="false" and updated theme if present.`);
180
+ }
181
+
182
+
183
+ function removeOldSplashImages() {
184
+ const drawableFolders = [
185
+ "drawable",
186
+ "drawable-land-hdpi",
187
+ "drawable-land-mdpi",
188
+ "drawable-land-xhdpi",
189
+ "drawable-land-xxhdpi",
190
+ "drawable-land-xxxhdpi",
191
+ "drawable-port-hdpi",
192
+ "drawable-port-mdpi",
193
+ "drawable-port-xhdpi",
194
+ "drawable-port-xxhdpi",
195
+ "drawable-port-xxxhdpi"
196
+ ];
197
+
198
+ drawableFolders.forEach((folder) => {
199
+ const filePath = path.join(projectFolder, "android", "app", "src", "main", "res", folder, "splash.png");
200
+ if (fs.existsSync(filePath)) {
201
+ fs.unlinkSync(filePath);
202
+ console.log(`Removed: ${filePath}`);
203
+ } else {
204
+ console.log(`Not found (skipped): ${filePath}`);
205
+ }
206
+ });
207
+ }
208
+
209
+ function removeOldSplashStyle() {
210
+ const stylesPath = path.join(projectFolder, "android", "app", "src", "main", "res", "values", "styles.xml");
211
+
212
+ if (!fs.existsSync(stylesPath)) {
213
+ console.log(`styles.xml not found: ${stylesPath}`);
214
+ return;
215
+ }
216
+
217
+ let content = fs.readFileSync(stylesPath, "utf-8");
218
+
219
+ // Remove the <style name="AppTheme.NoActionBarLaunch">...</style> block
220
+ const regex = /<style\s+name="AppTheme\.NoActionBarLaunch"[\s\S]*?<\/style>/g;
221
+ if (regex.test(content)) {
222
+ content = content.replace(regex, "");
223
+ fs.writeFileSync(stylesPath, content, "utf-8");
224
+ console.log("Removed AppTheme.NoActionBarLaunch from styles.xml");
225
+ } else {
226
+ console.log("AppTheme.NoActionBarLaunch style not found, skipped");
227
+ }
228
+ }
229
+
230
+ // Perform the tasks
231
+ try {
232
+ console.log("Starting splash screen setup...");
233
+ copyFile(sourceSplashIcon, destinationSplashIcon);
234
+ copyFile(sourceSplashXML, destinationSplashXML);
235
+ updateAndroidManifest();
236
+ console.log("Splash screen setup completed.");
237
+
238
+ console.log("Removing default splash.png files...");
239
+ removeOldSplashImages()
240
+ removeOldSplashStyle()
241
+
242
+ } catch (error) {
243
+ console.error(`Error: ${error.message}`);
244
+ process.exit(1);
245
+ }
246
+
247
+
248
+
@@ -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>
@@ -44,6 +44,14 @@ const storeNames = {
44
44
 
45
45
 
46
46
 
47
+ const ffmpegUsedPackages = [
48
+ "vfx.green.editor",
49
+ "audio.music.sound.editor",
50
+ "video.to.gif.maker"
51
+ ];
52
+
53
+
54
+
47
55
 
48
56
  let isAdmobFound = false;
49
57
 
@@ -481,25 +489,26 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
481
489
 
482
490
 
483
491
 
484
-
492
+ // List of package IDs for which minify should be false
485
493
 
486
494
 
487
- if (/minifyEnabled\s+false/.test(updatedGradleContent)) {
488
- updatedGradleContent = updatedGradleContent.replace(/minifyEnabled\s+false/, 'minifyEnabled true');
489
- console.log('Replaced minifyEnabled false with true.');
490
- } else if (!/minifyEnabled\s+true/.test(updatedGradleContent)) {
491
- // Only insert if minifyEnabled (true or false) is NOT present
492
- if (/buildTypes\s*{[\s\S]*?release\s*{/.test(updatedGradleContent)) {
493
- updatedGradleContent = updatedGradleContent.replace(
494
- /(buildTypes\s*{[\s\S]*?release\s*{)/,
495
- '$1\n minifyEnabled true'
496
- );
497
- console.log('✅ Inserted minifyEnabled true into release block.');
498
- } else {
499
- console.log('⚠️ Warning: buildTypes > release block not found. minifyEnabled was not added.');
500
- }
495
+ // Determine desired minify value
496
+ const desiredMinify = ffmpegUsedPackages.includes(_appPackageId) ? 'false' : 'true';
497
+
498
+ // Check if minifyEnabled is already present
499
+ if (/minifyEnabled\s+(true|false)/.test(updatedGradleContent)) {
500
+ // Replace existing value with desired
501
+ updatedGradleContent = updatedGradleContent.replace(/minifyEnabled\s+(true|false)/, `minifyEnabled ${desiredMinify}`);
502
+ console.log(`Replaced minifyEnabled with ${desiredMinify}.`);
503
+ } else if (/buildTypes\s*{[\s\S]*?release\s*{/.test(updatedGradleContent)) {
504
+ // Insert minifyEnabled if not present
505
+ updatedGradleContent = updatedGradleContent.replace(
506
+ /(buildTypes\s*{[\s\S]*?release\s*{)/,
507
+ `$1\n minifyEnabled ${desiredMinify}`
508
+ );
509
+ console.log(`✅ Inserted minifyEnabled ${desiredMinify} into release block.`);
501
510
  } else {
502
- console.log('ℹ️ minifyEnabled true already present. No change needed.');
511
+ console.log('⚠️ Warning: buildTypes > release block not found. minifyEnabled was not added.');
503
512
  }
504
513
 
505
514
 
@@ -567,7 +576,10 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
567
576
  if(currentMinSdkVersion==23 || currentMinSdkVersion==24)
568
577
  {
569
578
  if (storeName === "SamsungStore" || storeName === "PlayStore" ||
570
- _appPackageId=="vfx.green.editor" || _appPackageId=="audio.music.sound.editor" || _appPackageId=="video.to.gif.maker") {
579
+ //_appPackageId=="vfx.green.editor" || _appPackageId=="audio.music.sound.editor" || _appPackageId=="video.to.gif.maker"
580
+
581
+ ffmpegUsedPackages.includes(_appPackageId)
582
+ ) {
571
583
  if (currentMinSdkVersion !== 24) {
572
584
  variablesGradleContent = variablesGradleContent.replace(/minSdkVersion\s*=\s*\d+/, 'minSdkVersion = 24');
573
585
  console.log('minSdkVersion updated to 24 for SamsungStore & PlayStore');
@@ -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
+ }
@@ -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": "1.9.1",
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": "1.9.3",
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,86 +1,86 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
-
4
- const projectRoot = path.resolve(__dirname, "../../../"); // Your project's root
5
- const commonBuildPath = path.join(__dirname, "../files"); // Path to common files
6
- const buildCodeplayPath = path.join(commonBuildPath, "buildCodeplay"); // Correct path
7
- const packageJsonPath = path.join(projectRoot, "package.json");
8
-
9
- // Ensure package.json exists
10
- if (!fs.existsSync(packageJsonPath)) {
11
- process.stderr.write("❌ package.json not found!\n");
12
- process.exit(1);
13
- }
14
-
15
- function copyFolderSync(source, destination) {
16
- try {
17
- fs.cpSync(source, destination, { recursive: true });
18
- process.stdout.write(`✅ Copied folder: ${source} -> ${destination}\n`);
19
- } catch (error) {
20
- process.stderr.write(`⚠️ Failed to copy folder: ${source} - ${error.message}\n`);
21
- }
22
- }
23
-
24
- // Copy all files from `common-build-files/files/` to the project root
25
- fs.readdirSync(commonBuildPath).forEach(file => {
26
- const sourcePath = path.join(commonBuildPath, file);
27
- const destPath = path.join(projectRoot, file);
28
-
29
- if (fs.statSync(sourcePath).isDirectory()) {
30
- copyFolderSync(sourcePath, destPath);
31
- } else {
32
- try {
33
- fs.copyFileSync(sourcePath, destPath);
34
- process.stdout.write(`✅ Copied file: ${file}\n`);
35
- } catch (error) {
36
- process.stderr.write(`⚠️ Failed to copy file: ${file} - ${error.message}\n`);
37
- }
38
- }
39
- });
40
-
41
- // Function to get the latest versioned file from files/buildCodeplay
42
- function getLatestFile(prefix) {
43
- if (!fs.existsSync(buildCodeplayPath)) return null; // Ensure directory exists
44
-
45
- const files = fs.readdirSync(buildCodeplayPath).filter(file => file.startsWith(prefix));
46
- if (files.length === 0) return null;
47
- files.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
48
- return files[0];
49
- }
50
-
51
- // Detect latest script versions
52
- const latestSplashScreen = getLatestFile("add-splash-screen-");
53
- const latestSplashAnimation = getLatestFile("setSplashAnimation-");
54
- const latestCodeplayBuild = getLatestFile("codeplayBeforeBuild-");
55
-
56
- const latestPackageIdModification = getLatestFile("packageidBaseModification-");
57
-
58
-
59
- // Update package.json
60
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
61
-
62
- // Ensure scripts object exists
63
- packageJson.scripts = packageJson.scripts || {};
64
-
65
- // Update or add necessary scripts
66
- if (latestCodeplayBuild) {
67
- packageJson.scripts["build"] = `node buildCodeplay/${latestCodeplayBuild} && node buildCodeplay/${latestPackageIdModification} && cross-env NODE_ENV=production vite build --logLevel warn`;
68
- }
69
- if (latestSplashScreen && latestSplashAnimation) {
70
- packageJson.scripts["capacitor:sync:after"] = ` node buildCodeplay/${latestSplashScreen} && node buildCodeplay/${latestSplashAnimation}`;
71
- //node buildCodeplay/ios-emi-admob-modification.js &&
72
- }
73
-
74
- packageJson.scripts["ionic:build"] = "npm run build";
75
- packageJson.scripts["ionic:serve"] = "npm run start";
76
- packageJson.scripts["build:storeid1"] = "vite build --mode storeid1";
77
- packageJson.scripts["build:storeid2"] = "vite build --mode storeid2";
78
- packageJson.scripts["build:storeid3"] = "vite build --mode storeid3";
79
- packageJson.scripts["build:storeid4"] = "vite build --mode storeid4";
80
- packageJson.scripts["build:storeid5"] = "vite build --mode storeid5";
81
- //packageJson.scripts["build:storeid6"] = "vite build --mode storeid6";
82
- packageJson.scripts["build:storeid7"] = "vite build --mode storeid7";
83
- packageJson.scripts["build:storeid8"] = "vite build --mode storeid8";
84
- // Save changes
85
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
86
- process.stdout.write("✅ package.json updated!\n");
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const projectRoot = path.resolve(__dirname, "../../../"); // Your project's root
5
+ const commonBuildPath = path.join(__dirname, "../files"); // Path to common files
6
+ const buildCodeplayPath = path.join(commonBuildPath, "buildCodeplay"); // Correct path
7
+ const packageJsonPath = path.join(projectRoot, "package.json");
8
+
9
+ // Ensure package.json exists
10
+ if (!fs.existsSync(packageJsonPath)) {
11
+ process.stderr.write("❌ package.json not found!\n");
12
+ process.exit(1);
13
+ }
14
+
15
+ function copyFolderSync(source, destination) {
16
+ try {
17
+ fs.cpSync(source, destination, { recursive: true });
18
+ process.stdout.write(`✅ Copied folder: ${source} -> ${destination}\n`);
19
+ } catch (error) {
20
+ process.stderr.write(`⚠️ Failed to copy folder: ${source} - ${error.message}\n`);
21
+ }
22
+ }
23
+
24
+ // Copy all files from `common-build-files/files/` to the project root
25
+ fs.readdirSync(commonBuildPath).forEach(file => {
26
+ const sourcePath = path.join(commonBuildPath, file);
27
+ const destPath = path.join(projectRoot, file);
28
+
29
+ if (fs.statSync(sourcePath).isDirectory()) {
30
+ copyFolderSync(sourcePath, destPath);
31
+ } else {
32
+ try {
33
+ fs.copyFileSync(sourcePath, destPath);
34
+ process.stdout.write(`✅ Copied file: ${file}\n`);
35
+ } catch (error) {
36
+ process.stderr.write(`⚠️ Failed to copy file: ${file} - ${error.message}\n`);
37
+ }
38
+ }
39
+ });
40
+
41
+ // Function to get the latest versioned file from files/buildCodeplay
42
+ function getLatestFile(prefix) {
43
+ if (!fs.existsSync(buildCodeplayPath)) return null; // Ensure directory exists
44
+
45
+ const files = fs.readdirSync(buildCodeplayPath).filter(file => file.startsWith(prefix));
46
+ if (files.length === 0) return null;
47
+ files.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
48
+ return files[0];
49
+ }
50
+
51
+ // Detect latest script versions
52
+ const latestSplashScreen = getLatestFile("add-splash-screen-");
53
+ const latestSplashAnimation = getLatestFile("setSplashAnimation-");
54
+ const latestCodeplayBuild = getLatestFile("codeplayBeforeBuild-");
55
+
56
+ const latestPackageIdModification = getLatestFile("packageidBaseModification-");
57
+
58
+
59
+ // Update package.json
60
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
61
+
62
+ // Ensure scripts object exists
63
+ packageJson.scripts = packageJson.scripts || {};
64
+
65
+ // Update or add necessary scripts
66
+ if (latestCodeplayBuild) {
67
+ packageJson.scripts["build"] = `node buildCodeplay/${latestCodeplayBuild} && node buildCodeplay/${latestPackageIdModification} && cross-env NODE_ENV=production vite build --logLevel warn`;
68
+ }
69
+ if (latestSplashScreen && latestSplashAnimation) {
70
+ packageJson.scripts["capacitor:sync:after"] = ` node buildCodeplay/${latestSplashScreen} && node buildCodeplay/${latestSplashAnimation}`;
71
+ //node buildCodeplay/ios-emi-admob-modification.js &&
72
+ }
73
+
74
+ packageJson.scripts["ionic:build"] = "npm run build";
75
+ packageJson.scripts["ionic:serve"] = "npm run start";
76
+ packageJson.scripts["build:storeid1"] = "vite build --mode storeid1";
77
+ packageJson.scripts["build:storeid2"] = "vite build --mode storeid2";
78
+ packageJson.scripts["build:storeid3"] = "vite build --mode storeid3";
79
+ packageJson.scripts["build:storeid4"] = "vite build --mode storeid4";
80
+ packageJson.scripts["build:storeid5"] = "vite build --mode storeid5";
81
+ //packageJson.scripts["build:storeid6"] = "vite build --mode storeid6";
82
+ packageJson.scripts["build:storeid7"] = "vite build --mode storeid7";
83
+ packageJson.scripts["build:storeid8"] = "vite build --mode storeid8";
84
+ // Save changes
85
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
86
+ process.stdout.write("✅ package.json updated!\n");
@@ -1,77 +1,77 @@
1
- // Define file prefixes to delete
2
- const filePrefixes = [
3
- "add-splash-screen",
4
- "setSplashAnimation",
5
- "codeplayBeforeBuild",
6
- "finalrelease"
7
- ];
8
-
9
- const fs = require("fs");
10
- const path = require("path");
11
-
12
- const projectRoot = path.resolve(__dirname, "../../../"); // Project root
13
- const commonBuildPath = path.join(__dirname, "../files"); // Path where files were copied from
14
- const splashXmlPath = path.join(projectRoot, "buildCodeplay"); // Path to splashxml folder
15
-
16
- process.stdout.write("🚀 Uninstalling: Removing old and copied files...\n");
17
-
18
- const removeDirectory = (dirPath) => {
19
- if (fs.existsSync(dirPath)) {
20
- fs.readdirSync(dirPath).forEach(file => {
21
- const currentPath = path.join(dirPath, file);
22
- if (fs.lstatSync(currentPath).isDirectory()) {
23
- removeDirectory(currentPath);
24
- } else {
25
- fs.unlinkSync(currentPath);
26
- }
27
- });
28
- fs.rmdirSync(dirPath);
29
- process.stdout.write(`🗑️ Removed folder: ${dirPath}\n`);
30
- }
31
- };
32
-
33
- removeDirectory(splashXmlPath);
34
- removeDirectory(path.join(projectRoot, "splashxml")); // Remove old splashxml folder
35
-
36
- // Step 1: Find all matching files in the project directory
37
- const filePatternsToRemove = [
38
- /^add-splash-screen-.*$/,
39
- /^setSplashAnimation-.*$/,
40
- /^codeplayBeforeBuild-.*$/,
41
- /^modify-plugin-xml\.xml$/,
42
- /^finalrelease.*$/,
43
- /^iap-install-\d+(\.\d+)?\.js$/,
44
- /^\.env\.storeid[1-7]$/,
45
- /^modify-plugin-xml\.js$/
46
- ];
47
-
48
- const filesInProject = fs.readdirSync(projectRoot);
49
-
50
- filesInProject.forEach(file => {
51
- if (filePatternsToRemove.some(pattern => pattern.test(file))) {
52
- const filePath = path.join(projectRoot, file);
53
- try {
54
- fs.unlinkSync(filePath);
55
- process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
56
- } catch (error) {
57
- process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
58
- }
59
- }
60
- });
61
-
62
- // Remove files listed in commonBuildPath
63
- if (fs.existsSync(commonBuildPath)) {
64
- fs.readdirSync(commonBuildPath).forEach(file => {
65
- const destPath = path.join(projectRoot, file);
66
- if (fs.existsSync(destPath)) {
67
- try {
68
- fs.unlinkSync(destPath);
69
- process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
70
- } catch (error) {
71
- process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
72
- }
73
- }
74
- });
75
- }
76
-
77
- process.stdout.write("✅ Uninstall cleanup complete!\n");
1
+ // Define file prefixes to delete
2
+ const filePrefixes = [
3
+ "add-splash-screen",
4
+ "setSplashAnimation",
5
+ "codeplayBeforeBuild",
6
+ "finalrelease"
7
+ ];
8
+
9
+ const fs = require("fs");
10
+ const path = require("path");
11
+
12
+ const projectRoot = path.resolve(__dirname, "../../../"); // Project root
13
+ const commonBuildPath = path.join(__dirname, "../files"); // Path where files were copied from
14
+ const splashXmlPath = path.join(projectRoot, "buildCodeplay"); // Path to splashxml folder
15
+
16
+ process.stdout.write("🚀 Uninstalling: Removing old and copied files...\n");
17
+
18
+ const removeDirectory = (dirPath) => {
19
+ if (fs.existsSync(dirPath)) {
20
+ fs.readdirSync(dirPath).forEach(file => {
21
+ const currentPath = path.join(dirPath, file);
22
+ if (fs.lstatSync(currentPath).isDirectory()) {
23
+ removeDirectory(currentPath);
24
+ } else {
25
+ fs.unlinkSync(currentPath);
26
+ }
27
+ });
28
+ fs.rmdirSync(dirPath);
29
+ process.stdout.write(`🗑️ Removed folder: ${dirPath}\n`);
30
+ }
31
+ };
32
+
33
+ removeDirectory(splashXmlPath);
34
+ removeDirectory(path.join(projectRoot, "splashxml")); // Remove old splashxml folder
35
+
36
+ // Step 1: Find all matching files in the project directory
37
+ const filePatternsToRemove = [
38
+ /^add-splash-screen-.*$/,
39
+ /^setSplashAnimation-.*$/,
40
+ /^codeplayBeforeBuild-.*$/,
41
+ /^modify-plugin-xml\.xml$/,
42
+ /^finalrelease.*$/,
43
+ /^iap-install-\d+(\.\d+)?\.js$/,
44
+ /^\.env\.storeid[1-7]$/,
45
+ /^modify-plugin-xml\.js$/
46
+ ];
47
+
48
+ const filesInProject = fs.readdirSync(projectRoot);
49
+
50
+ filesInProject.forEach(file => {
51
+ if (filePatternsToRemove.some(pattern => pattern.test(file))) {
52
+ const filePath = path.join(projectRoot, file);
53
+ try {
54
+ fs.unlinkSync(filePath);
55
+ process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
56
+ } catch (error) {
57
+ process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
58
+ }
59
+ }
60
+ });
61
+
62
+ // Remove files listed in commonBuildPath
63
+ if (fs.existsSync(commonBuildPath)) {
64
+ fs.readdirSync(commonBuildPath).forEach(file => {
65
+ const destPath = path.join(projectRoot, file);
66
+ if (fs.existsSync(destPath)) {
67
+ try {
68
+ fs.unlinkSync(destPath);
69
+ process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
70
+ } catch (error) {
71
+ process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
72
+ }
73
+ }
74
+ });
75
+ }
76
+
77
+ process.stdout.write("✅ Uninstall cleanup complete!\n");