codeplay-common 1.8.8 → 1.9.0

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
@@ -57,22 +57,38 @@ function updateAndroidManifest() {
57
57
  const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
58
58
 
59
59
 
60
+ let logErrorMessage="";
61
+
60
62
  const RESIZEABLE_ACTIVITY = config.android?.RESIZEABLE_ACTIVITY;
63
+ const orientation = config.android?.ORIENTATION;
61
64
 
62
65
  // 1️⃣ Check if it’s missing
63
66
  if (RESIZEABLE_ACTIVITY === undefined) {
64
- console.error('❌ Missing android.RESIZEABLE_ACTIVITY option in capacitor.config.json.');
65
- process.exit(1);
67
+ logErrorMessage+='❌ Missing android.RESIZEABLE_ACTIVITY option in capacitor.config.json.\n';
66
68
  }
67
69
 
68
70
  // 2️⃣ Check if it’s not boolean (true/false only)
69
- if (typeof RESIZEABLE_ACTIVITY !== 'boolean') {
70
- console.error('❌ Invalid android.RESIZEABLE_ACTIVITY value. Please use only true or false (without quotes).');
71
- process.exit(1);
71
+ else if (typeof RESIZEABLE_ACTIVITY !== 'boolean') {
72
+ logErrorMessage+='❌ Invalid android.RESIZEABLE_ACTIVITY value. Please use only true or false (without quotes).\n';
72
73
  }
73
74
 
74
75
 
75
76
 
77
+ if (!orientation) {
78
+ logErrorMessage+='❌ Missing android.ORIENTATION option in capacitor.config.json.\n';
79
+ }
80
+
81
+ else if(orientation!="portrait" && orientation!="landscape" && orientation!="auto")
82
+ {
83
+ logErrorMessage+='❌ Spelling mistake in android.ORIENTATION option in capacitor.config.json. Please use only ["portrait" "landscape" "auto"]\n';
84
+ }
85
+
86
+ if(logErrorMessage!="")
87
+ {
88
+ console.error(logErrorMessage);
89
+ process.exit(1)
90
+ }
91
+
76
92
 
77
93
  let manifestContent = fs.readFileSync(androidManifestPath, "utf-8");
78
94
 
@@ -107,23 +123,6 @@ function updateAndroidManifest() {
107
123
 
108
124
 
109
125
 
110
-
111
- const orientation = config.android?.ORIENTATION;
112
-
113
-
114
-
115
- if (!orientation) {
116
- console.error('❌ Missing android.orientation option in capacitor.config.json.');
117
- process.exit(1);
118
- }
119
-
120
- if(orientation!="portrait" && orientation!="landscape" && orientation!="auto")
121
- {
122
- console.error('❌ Spelling mistake in android.orientation option in capacitor.config.json. Please use only ["portrait" "landscape" "auto"]');
123
- process.exit(1);
124
- }
125
-
126
-
127
126
  if(orientation=="portrait"){
128
127
  // If android:screenOrientation is already present, update it
129
128
  if (updated.includes('android:screenOrientation=')) {
@@ -85,6 +85,65 @@ try {
85
85
 
86
86
 
87
87
 
88
+ const checkAppUniqueId=()=>{
89
+
90
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
91
+
92
+ const appUniqueId = config.android?.APP_UNIQUE_ID;
93
+ const RESIZEABLE_ACTIVITY = config.android?.RESIZEABLE_ACTIVITY;
94
+ const orientation = config.android?.ORIENTATION;
95
+
96
+
97
+ let logErrorMessage="";
98
+
99
+ // 1️⃣ Check if it’s missing
100
+ if (RESIZEABLE_ACTIVITY === undefined) {
101
+ logErrorMessage+='❌ Missing android.RESIZEABLE_ACTIVITY option in capacitor.config.json.\n';
102
+ }
103
+
104
+ // 2️⃣ Check if it’s not boolean (true/false only)
105
+ else if (typeof RESIZEABLE_ACTIVITY !== 'boolean') {
106
+ logErrorMessage+='❌ Invalid android.RESIZEABLE_ACTIVITY value. Please use only true or false (without quotes).\n';
107
+ }
108
+
109
+
110
+
111
+ if (!orientation) {
112
+ logErrorMessage+='❌ Missing android.ORIENTATION option in capacitor.config.json.\n';
113
+ }
114
+
115
+ else if(orientation!="portrait" && orientation!="landscape" && orientation!="auto")
116
+ {
117
+ logErrorMessage+='❌ Spelling mistake in android.ORIENTATION option in capacitor.config.json. Please use only ["portrait" "landscape" "auto"]\n';
118
+ }
119
+
120
+
121
+ if (!appUniqueId) {
122
+ logErrorMessage+='❌ APP_UNIQUE_ID is missing in capacitor.config.json.';
123
+ }
124
+
125
+ else if (!Number.isInteger(appUniqueId)) {
126
+ logErrorMessage+='❌ APP_UNIQUE_ID must be an integer. Example: 1, 2, 3, etc.';
127
+ }
128
+
129
+
130
+
131
+ if(logErrorMessage!="")
132
+ {
133
+ console.error(logErrorMessage);
134
+ process.exit(1)
135
+ }
136
+
137
+
138
+ console.log(`✅ APP_UNIQUE_ID is valid: ${appUniqueId}`);
139
+
140
+ }
141
+
142
+ checkAppUniqueId();
143
+
144
+
145
+
146
+
88
147
 
89
148
 
90
149
 
@@ -96,7 +155,7 @@ try {
96
155
  const baseDir = path.join(__dirname, "..", "src", "js");
97
156
 
98
157
  // Step 1: Find highest versioned folder like `editor-1.6`
99
- const editorDirs = fs.readdirSync(baseDir)
158
+ const editorDirs = fs.readdirSync(baseDir)
100
159
  .filter(name => /^editor-\d+\.\d+$/.test(name))
101
160
  .sort((a, b) => {
102
161
  const getVersion = str => str.match(/(\d+)\.(\d+)/).slice(1).map(Number);
@@ -151,7 +210,18 @@ else
151
210
  const os = require('os');
152
211
 
153
212
  const saveToGalleryAndSaveFileCheck_iOS = () => {
154
- const ROOT_DIR = path.resolve(__dirname, '../src');
213
+
214
+ // List of paths to scan
215
+ const SCAN_PATHS = [
216
+ path.resolve(__dirname, '../src/certificate'),
217
+ path.resolve(__dirname, '../src/pages'),
218
+ path.resolve(__dirname, '../src/js'),
219
+ path.resolve(__dirname, '../src/app.f7')
220
+ ];
221
+
222
+ // Directory to exclude
223
+ const EXCLUDED_DIR = path.resolve(__dirname, '../src/js/Ads');
224
+
155
225
  const ANDROID_MANIFEST_PATH = path.resolve(__dirname, '../android/app/src/main/AndroidManifest.xml');
156
226
 
157
227
 
@@ -171,43 +241,54 @@ const ANDROID_FILE_REGEX = /^(?!\s*\/\/).*['"](?:.*\/)?saveToGalleryAndSaveAnyFi
171
241
  let iosImportFound = false;
172
242
  let androidImportFound = false;
173
243
 
174
- function scanDirectory(dir) {
175
- const entries = fs.readdirSync(dir, { withFileTypes: true });
244
+ function scanDirectory(dir) {
245
+ const stat = fs.statSync(dir);
176
246
 
177
- for (let entry of entries) {
178
- const fullPath = path.join(dir, entry.name);
179
-
180
- if (entry.isDirectory()) {
181
- if (entry.name === 'node_modules') continue;
182
- scanDirectory(fullPath);
183
- } else if (entry.isFile() && ALLOWED_EXTENSIONS.some(ext => fullPath.endsWith(ext))) {
184
- const content = fs.readFileSync(fullPath, 'utf8');
185
-
186
- // Detect iOS version file imports
187
- if (IOS_FILE_REGEX.test(content)) {
188
- iosImportFound = true;
189
- if (!isMac) {
190
- console.error(`\n❌ ERROR: iOS-specific import detected in: ${fullPath}`);
191
- console.error(`🚫 STOPPED: This file should not be imported in Android/Windows/Linux builds.\n`);
192
- process.exit(1);
193
- }
194
- }
247
+ if (stat.isFile()) {
248
+ // Only scan allowed file extensions
249
+ if (ALLOWED_EXTENSIONS.some(ext => dir.endsWith(ext))) {
250
+ process.stdout.write(`\r🔍 Scanning: ${dir} `);
251
+
252
+ const content = fs.readFileSync(dir, 'utf8');
195
253
 
196
- // Detect Android version file imports (but ignore iOS ones)
197
- else if (ANDROID_FILE_REGEX.test(content) && !content.includes('-ios.js')) {
198
- androidImportFound = true;
254
+ if (IOS_FILE_REGEX.test(content)) {
255
+ iosImportFound = true;
256
+ if (!isMac) {
257
+ console.error(`\n❌ ERROR: iOS-specific import detected in: ${dir}`);
258
+ console.error(`🚫 STOPPED: This file should not be imported in Android/Windows/Linux builds.\n`);
259
+ process.exit(1);
199
260
  }
261
+ } else if (ANDROID_FILE_REGEX.test(content) && !content.includes('-ios.js')) {
262
+ androidImportFound = true;
200
263
  }
201
264
  }
265
+ }
266
+ else if (stat.isDirectory()) {
267
+ if (dir === EXCLUDED_DIR || path.basename(dir) === 'node_modules') return;
268
+
269
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
270
+ for (let entry of entries) {
271
+ scanDirectory(path.join(dir, entry.name));
272
+ }
273
+ }
274
+ }
275
+
276
+ // Run scan on all specified paths
277
+ for (let scanPath of SCAN_PATHS) {
278
+ if (fs.existsSync(scanPath)) {
279
+ scanDirectory(scanPath);
202
280
  }
281
+ }
282
+
203
283
 
204
- // Check src folder
284
+
285
+ /* // Check src folder
205
286
  if (!fs.existsSync(ROOT_DIR)) {
206
287
  console.warn(`⚠️ Warning: 'src' directory not found at: ${ROOT_DIR}`);
207
288
  return;
208
- }
289
+ } */
209
290
 
210
- scanDirectory(ROOT_DIR);
291
+ //scanDirectory(ROOT_DIR);
211
292
 
212
293
  // iOS Checks
213
294
  if (isMac && !iosImportFound) {
@@ -578,6 +659,11 @@ function checkAndCopyResources() {
578
659
 
579
660
 
580
661
 
662
+
663
+
664
+
665
+
666
+
581
667
  function getAdMobConfig() {
582
668
  if (!fileExists(configPath)) {
583
669
  throw new Error('❌ capacitor.config.json not found. Ensure this is a Capacitor project.');
@@ -731,10 +817,13 @@ try {
731
817
 
732
818
  checkAndCopyResources();
733
819
 
820
+
821
+
734
822
  const admobConfig = getAdMobConfig();
735
-
736
823
 
737
824
 
825
+
826
+
738
827
 
739
828
  // Proceed only if ADMOB_ENABLED is true
740
829
  if (admobConfig.ADMOB_ENABLED) {
@@ -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>
@@ -1,3 +1,10 @@
1
+ /*
2
+ Can be run like
3
+ node finalrelease
4
+ node finalrelease 1
5
+ node finalrelease "1,2,7"
6
+ */
7
+
1
8
  import { existsSync, readFileSync, readdirSync, promises, constants, writeFileSync, unlinkSync, mkdirSync, renameSync } from 'fs';
2
9
  import { join, resolve } from 'path';
3
10
  import { execSync } from 'child_process';
@@ -6,6 +13,12 @@ import { createInterface } from 'readline';
6
13
  import { fileURLToPath } from 'url';
7
14
  import { dirname } from 'path';
8
15
 
16
+ /* const path = require('path');
17
+ const fs = require('fs'); */
18
+
19
+ import fs from 'fs';
20
+ import path from 'path';
21
+
9
22
  // Define a mapping between store IDs and store names
10
23
  /* const storeNames = {
11
24
  "1": "PlayStore",
@@ -16,20 +29,21 @@ import { dirname } from 'path';
16
29
  const storeNames = {
17
30
  "1": "PlayStore",
18
31
  "2": "SamsungStore",
32
+ "7": "AmazonStore",
33
+
19
34
  "3": "MiStore",
20
35
  "4": "HuaweiStore",
21
36
  "5": "OppoStore",
22
37
  //"6": "iOSStore",
23
- "7": "AmazonStore",
24
38
  "8": "VivoStore"
25
39
  };
26
40
 
27
41
 
28
- //1=> Playstore 2=> SamsungStore 3=>miStore 4=>huaweiStore 5=>OppoStore 6=>iOSStore 7=> AmazonStore 8=> VivoStore
42
+ //1=> PlayStore 2=> SamsungStore 3=>MiStore 4=>HuaweiStore 5=>OppoStore 6=>iOSStore 7=> AmazonStore 8=> VivoStore
43
+
29
44
 
30
45
 
31
46
 
32
- let _appPackageId;
33
47
 
34
48
  let isAdmobFound = false;
35
49
 
@@ -38,6 +52,14 @@ const amazonMinSdkVersion=23;
38
52
  const androidManifestPath = join("android", "app", "src", "main", "AndroidManifest.xml");
39
53
 
40
54
 
55
+ const configPath = path.join(process.cwd(), 'capacitor.config.json');
56
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
57
+
58
+ const _appUniqueId = config.android?.APP_UNIQUE_ID;
59
+ const _appName=config.appName;
60
+ const _appPackageId=config.appId;
61
+
62
+
41
63
 
42
64
  const __filename = fileURLToPath(import.meta.url);
43
65
  const __dirname = dirname(__filename);
@@ -57,7 +79,7 @@ function getAdMobConfig() {
57
79
  const config = JSON.parse(readFileSync(capacitorConfigPath, 'utf8'));
58
80
  const admobConfig = config.plugins?.AdMob;
59
81
 
60
- _appPackageId=config.appId;
82
+ //_appPackageId=config.appId;
61
83
 
62
84
  if (!admobConfig) {
63
85
  throw new Error('❌ AdMob configuration is missing in capacitor.config.json.');
@@ -352,8 +374,31 @@ console.log(`ℹ️ IAP Configurations - PlayStore: ${playstore}, Samsung: ${sa
352
374
 
353
375
 
354
376
  // Get the store ID from the command line arguments
355
- const storeIdArg = process.argv[2]; // Get the store ID from the command line
356
- const storeIds = storeIdArg ? [storeIdArg] : Object.keys(storeNames);//["1", "2", "7"]; // If a specific ID is provided, use it; otherwise, use all store IDs
377
+ /* const storeIdArg = ["2","3"]//process.argv[2]; // Get the store ID from the command line
378
+ const storeIds = storeIdArg ? storeIdArg : Object.keys(storeNames);//["1", "2", "7"]; // If a specific ID is provided, use it; otherwise, use all store IDs
379
+
380
+ debugger; */
381
+
382
+ let storeIdArg = process.argv[2]; // command-line argument
383
+ let storeIds;
384
+
385
+ if (storeIdArg) {
386
+ try {
387
+ // Try parsing as JSON array first
388
+ const parsed = JSON.parse(storeIdArg);
389
+ if (Array.isArray(parsed)) {
390
+ storeIds = parsed.map(String); // ensure strings
391
+ } else {
392
+ storeIds = [parsed.toString()];
393
+ }
394
+ } catch (e) {
395
+ // Not JSON, assume comma-separated string
396
+ storeIds = storeIdArg.split(",").map(s => s.trim());
397
+ }
398
+ } else {
399
+ // No argument, use all store IDs
400
+ storeIds = Object.keys(storeNames);
401
+ }
357
402
 
358
403
 
359
404
  // Store the original minSdkVersion globally
@@ -483,10 +528,21 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
483
528
 
484
529
  if (storeName === "SamsungStore") {
485
530
  // For SamsungStore, rename to versionCode value only
486
- newFileName = `${finalVersionCode}.aab`;
531
+ //newFileName = `${finalVersionCode}.aab`;
532
+ newFileName=`${_appUniqueId}_${_appName.replaceAll(" ","_")}-${(storeName.toUpperCase()).replace("STORE","")}-b${finalVersionCode}-v${finalVersionName.replace(/\./g,'_')}.aab`
487
533
  } else {
488
534
  // For other stores, use the standard naming format
489
- newFileName = `app-release-signed-${storeName}-b${finalVersionCode}-v${finalVersionName}.aab`;
535
+ //newFileName = `app-release-signed-${storeName}-b${finalVersionCode}-v${finalVersionName}.aab`;
536
+
537
+ newFileName=`${_appUniqueId}_${_appName.replaceAll(" ","_")}-${(storeName.toUpperCase()).replace("STORE","")}-b${finalVersionCode}-v${finalVersionName}.aab`
538
+
539
+
540
+ /*
541
+ const _appUniqueId = config.android?.APP_UNIQUE_ID;
542
+ const _appName=config.appName;
543
+ const _appPackageId=config.appId;
544
+ */
545
+
490
546
  }
491
547
 
492
548
  //storeName="amazon"
@@ -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.8.8",
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.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,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`;
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");