codeplay-common 1.4.9 → 1.5.1

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.
@@ -6,13 +6,13 @@ const plist = require('plist');
6
6
  // Expected plugin list with minimum versions
7
7
  const requiredPlugins = [
8
8
  { pattern: /backbutton-(\d+\.\d+)\.js$/, minVersion: '1.1', required: true },
9
- { pattern: /common-(\d+\.\d+)\.js$/, minVersion: '3.3', required: true },
9
+ { pattern: /common-(\d+\.\d+)\.js$/, minVersion: '3.4', required: true },
10
10
  { pattern: /localization_settings-(\d+\.\d+)\.js$/, minVersion: '1.1', required: true },
11
11
  { pattern: /localization-(\d+\.\d+)\.js$/, minVersion: '1.2', required: true },
12
12
  { pattern: /localNotification-(\d+\.\d+)\.js$/, minVersion: '2.2', required: true },
13
13
  { pattern: /localNotification_AppSettings-(\d+\.\d+)\.js$/, minVersion: '1.0', required: true },
14
14
  { pattern: /onesignal-(\d+\.\d+)\.js$/, minVersion: '2.1', required: true },
15
- { pattern: /saveToGalleryAndSaveAnyFile-(\d+\.\d+)(-ios)?\.js$/, minVersion: '2.1', required: true },
15
+ { pattern: /saveToGalleryAndSaveAnyFile-(\d+\.\d+)(-ios)?\.js$/, minVersion: '2.3', required: true },
16
16
  { pattern: /Ads[\/\\]IAP-(\d+\.\d+)$/, minVersion: '2.1', isFolder: true },
17
17
  { pattern: /Ads[\/\\]admob-emi-(\d+\.\d+)\.js$/, minVersion: '2.6', required: true }
18
18
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "1.4.9",
3
+ "version": "1.5.1",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",
@@ -1,587 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const child_process = require('child_process');
4
- const readline = require('readline');
5
-
6
- // Define a mapping between store IDs and store names
7
- const storeNames = {
8
- "1": "PlayStore",
9
- "2": "SamsungStore",
10
- "7": "AmazonStore"
11
- };
12
-
13
- const amazonMinSdkVersion=23;
14
-
15
- const androidManifestPath = path.join("android", "app", "src", "main", "AndroidManifest.xml");
16
-
17
-
18
-
19
- const admobConfigPath = path.join('src', 'js','Ads', 'admob-ad-configuration.json');
20
- let admobConfig;
21
- try {
22
- admobConfig = JSON.parse(fs.readFileSync(admobConfigPath, 'utf8'));
23
- } catch (err) {
24
- console.error("❌ Failed to read admob-ad-configuration.json", err);
25
- process.exit(1);
26
- }
27
-
28
-
29
-
30
-
31
- const checkCommonFileStoreId=()=>{
32
- const possibleConfigFiles = ['vite.config.mjs', 'vite.config.js'];
33
- let viteConfigPath;
34
- for (const configFile of possibleConfigFiles) {
35
- const fullPath = path.resolve( configFile);
36
- if (fs.existsSync(fullPath)) {
37
- viteConfigPath = fullPath;
38
- break;
39
- }
40
- }
41
-
42
- if (!viteConfigPath) {
43
- console.error('❌ Error: No vite.config.mjs or vite.config.js file found.');
44
- process.exit(1);
45
- }
46
-
47
- try {
48
- // Read vite config file
49
- const viteConfigContent = fs.readFileSync(viteConfigPath, 'utf-8');
50
-
51
- // Extract @common alias path
52
- const aliasPattern = /'@common':\s*path\.resolve\(__dirname,\s*'(.+?)'\)/;
53
- const match = viteConfigContent.match(aliasPattern);
54
-
55
- if (!match) {
56
- console.error(`❌ Error: @common alias not found in ${viteConfigPath}`);
57
- process.exit(1);
58
- }
59
-
60
- const commonFilePath = match[1];
61
- const resolvedCommonPath = path.resolve(__dirname, commonFilePath);
62
-
63
- // Read the common file content
64
- if (!fs.existsSync(resolvedCommonPath)) {
65
- console.error(`❌ Error: Resolved common file does not exist: ${resolvedCommonPath}`);
66
- process.exit(1);
67
- }
68
-
69
- const commonFileContent = fs.readFileSync(resolvedCommonPath, 'utf-8');
70
-
71
- // Check for the _storeid export line
72
- const storeIdPattern = /export\s+let\s+_storeid\s*=\s*import\.meta\.env\.VITE_STORE_ID\s*\|\|\s*1\s*;/;
73
- if (!storeIdPattern.test(commonFileContent)) {
74
- console.error(`❌ Error: _storeid value is wrong in ${commonFilePath}`);
75
- process.exit(1);
76
- }
77
-
78
- console.log(commonFilePath,'Success - No problem found');
79
- } catch (error) {
80
- console.error('❌ Error:', error);
81
- process.exit(1);
82
- }
83
-
84
- }
85
-
86
- const checkIsTestingInAdmob=()=>{
87
-
88
- if (admobConfig.config && admobConfig.config.isTesting === true) {
89
- console.error(`❌ Problem found while generating the AAB file. Please change "isTesting: true" to "isTesting: false" in the "admob-ad-configuration.json" file.`);
90
- process.exit(1); // Exit with an error code to halt the process
91
- } else {
92
- console.log('✅ No problem found. "isTesting" is either already false or not defined.');
93
- }
94
- }
95
-
96
- const checkIsAdsDisableByReturnStatement=()=>{
97
-
98
-
99
- const adsFolder = path.join('src', 'js', 'Ads');
100
- const filePattern = /^admob-emi-(\d+\.)+\d+\.js$/;
101
-
102
- // Step 1: Find the admob file
103
- const files = fs.readdirSync(adsFolder);
104
- const admobFile = files.find(f => filePattern.test(f));
105
-
106
- if (!admobFile) {
107
- console.log('❌ No Admob file found.');
108
- process.exit(1);
109
- }
110
-
111
- const filePath = path.join(adsFolder, admobFile);
112
- const content = fs.readFileSync(filePath, 'utf-8');
113
-
114
- // Step 2: Extract the adsOnDeviceReady function body
115
- const functionRegex = /async\s+function\s+adsOnDeviceReady\s*\([^)]*\)\s*{([\s\S]*?)^}/m;
116
- const match = content.match(functionRegex);
117
-
118
- if (!match) {
119
- console.log(`❌ Function 'adsOnDeviceReady' not found in file: ${admobFile}`);
120
- process.exit(1);
121
- }
122
-
123
- const body = match[1];
124
- const lines = body.split('\n').map(line => line.trim());
125
-
126
- // Step 3: Skip blank lines and comments, get the first real code line
127
- let firstCodeLine = '';
128
- for (const line of lines) {
129
- if (line === '' || line.startsWith('//')) continue;
130
- firstCodeLine = line;
131
- break;
132
- }
133
-
134
- // Step 4: Block if it's any of the unwanted returns
135
- const badReturnPattern = /^return\s*(true|false)?\s*;?$/;
136
-
137
- if (badReturnPattern.test(firstCodeLine)) {
138
- console.log(`❌ BLOCKED in file '${admobFile}': First active line in 'adsOnDeviceReady' is '${firstCodeLine}'`);
139
- process.exit(2);
140
- } else {
141
- console.log(`✅ Safe: No early return (true/false) found in 'adsOnDeviceReady' of file '${admobFile}'.`);
142
- }
143
- }
144
-
145
-
146
-
147
- const addPermission_AD_ID=()=>{
148
-
149
- const admobPluginXmlPath = path.join('node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
150
-
151
-
152
- fs.access(admobPluginXmlPath, fs.constants.F_OK, (err) => {
153
- if (err) {
154
- isAdmobFound = false;
155
- } else {
156
- isAdmobFound = true;
157
- }
158
- });
159
-
160
-
161
- if (isAdmobFound) {
162
- // Check if AndroidManifest.xml exists
163
- if (fs.existsSync(androidManifestPath)) {
164
- // Read the content of AndroidManifest.xml
165
- let manifestContent = fs.readFileSync(androidManifestPath, 'utf8');
166
-
167
- // Check if the ad_id permission already exists
168
- const adIdPermission = '<uses-permission android:name="com.google.android.gms.permission.AD_ID" />';
169
- if (!manifestContent.includes(adIdPermission)) {
170
- console.log("ad_id permission not found. Adding to AndroidManifest.xml.");
171
-
172
- // Add the ad_id permission before the closing </manifest> tag
173
- manifestContent = manifestContent.replace('</manifest>', ` ${adIdPermission}\n</manifest>`);
174
-
175
- // Write the updated manifest content back to AndroidManifest.xml
176
- fs.writeFileSync(androidManifestPath, manifestContent, 'utf8');
177
- console.log("✅ ad_id permission added successfully.");
178
- } else {
179
- console.log("ℹ️ ad_id permission already exists in AndroidManifest.xml.");
180
- }
181
- } else {
182
- console.error("❌ AndroidManifest.xml not found at the specified path.");
183
- }
184
- } else {
185
- console.log("\x1b[33m%s\x1b[0m", "⚠️ No admob found, so permission.AD_ID is not added");
186
- }
187
- }
188
-
189
-
190
- checkCommonFileStoreId();
191
- checkIsTestingInAdmob();
192
- checkIsAdsDisableByReturnStatement()
193
-
194
-
195
- let isAdmobFound = true;
196
- addPermission_AD_ID()
197
-
198
-
199
-
200
- const { playstore, samsung, amazon } = admobConfig.IAP;
201
- console.log(`ℹ️ IAP Configurations - PlayStore: ${playstore}, Samsung: ${samsung}, Amazon: ${amazon}`);
202
-
203
-
204
-
205
-
206
-
207
-
208
- // Get the store ID from the command line arguments
209
- const storeIdArg = process.argv[2]; // Get the store ID from the command line
210
- const storeIds = storeIdArg ? [storeIdArg] : ["1", "2", "7"]; // If a specific ID is provided, use it; otherwise, use all store IDs
211
-
212
- // Store the original minSdkVersion globally
213
- let originalMinSdkVersion;
214
-
215
- // Remove any existing AAB files before starting the build process
216
- const aabDirectory = path.join("android", "app", "build", "outputs", "bundle", "release");
217
- if (fs.existsSync(aabDirectory)) {
218
- const files = fs.readdirSync(aabDirectory).filter(file => file.endsWith('.aab'));
219
- files.forEach(file => {
220
- const filePath = path.join(aabDirectory, file);
221
- fs.unlinkSync(filePath);
222
- console.log(`ℹ️ Deleted existing AAB file: ${file}`);
223
- });
224
- }
225
-
226
- const aabOutputDir = path.join("AAB");
227
- if (!fs.existsSync(aabOutputDir)) {
228
- fs.mkdirSync(aabOutputDir);
229
- console.log(`Created directory: ${aabOutputDir}`);
230
- }
231
-
232
- if (fs.existsSync(aabOutputDir)) {
233
- const files = fs.readdirSync(aabOutputDir).filter(file => file.endsWith('.aab'));
234
- files.forEach(file => {
235
- const filePath = path.join(aabOutputDir, file);
236
- fs.unlinkSync(filePath);
237
- console.log(`Deleted existing AAB file: ${file}`);
238
- });
239
- }
240
-
241
-
242
- // Extract version code and version name from build.gradle
243
- const gradleFilePath = path.join("android", "app", "build.gradle");
244
- const gradleContent = fs.readFileSync(gradleFilePath, 'utf8');
245
-
246
- const versionCodeMatch = gradleContent.match(/versionCode\s+(\d+)/);
247
- const versionNameMatch = gradleContent.match(/versionName\s+"([^"]+)"/);
248
-
249
- const versionCode = versionCodeMatch ? versionCodeMatch[1] : '';
250
- const versionName = versionNameMatch ? versionNameMatch[1] : '';
251
-
252
- // Display the current versionCode and versionName
253
- console.log(`Current versionCode: ${versionCode}`);
254
- console.log(`Current versionName: ${versionName}`);
255
-
256
- // Create an interface for user input
257
- const rl = readline.createInterface({
258
- input: process.stdin,
259
- output: process.stdout
260
- });
261
-
262
- // Ask for new versionCode
263
- rl.question('Enter new versionCode (press enter to keep current): ', (newVersionCode) => {
264
- const finalVersionCode = newVersionCode || versionCode; // Use existing if no input
265
-
266
- // Ask for new versionName
267
- rl.question('Enter new versionName (press enter to keep current): ', (newVersionName) => {
268
- const finalVersionName = newVersionName || versionName; // Use existing if no input
269
-
270
- // Log the final version details
271
- console.log(`📦 Final versionCode: ${finalVersionCode}`);
272
- console.log(`📝 Final versionName: ${finalVersionName}`);
273
-
274
-
275
-
276
- // Update build.gradle with the new version details
277
- let updatedGradleContent = gradleContent
278
- .replace(/versionCode\s+\d+/, `versionCode ${finalVersionCode}`)
279
- .replace(/versionName\s+"[^"]+"/, `versionName "${finalVersionName}"`);
280
-
281
- // Check if resConfigs "en" already exists
282
- const resConfigsLine = ' resConfigs "en"';
283
- if (!updatedGradleContent.includes(resConfigsLine)) {
284
- // Add resConfigs "en" below versionName
285
- updatedGradleContent = updatedGradleContent.replace(/versionName\s+"[^"]+"/, `versionName "${finalVersionName}"\n${resConfigsLine}`);
286
- } else {
287
- console.log('ℹ️ resConfigs "en" already exists in build.gradle.');
288
- }
289
-
290
-
291
-
292
-
293
-
294
-
295
- if (/minifyEnabled\s+false/.test(updatedGradleContent)) {
296
- updatedGradleContent = updatedGradleContent.replace(/minifyEnabled\s+false/, 'minifyEnabled true');
297
- console.log('Replaced minifyEnabled false with true.');
298
- } else if (!/minifyEnabled\s+true/.test(updatedGradleContent)) {
299
- // Only insert if minifyEnabled (true or false) is NOT present
300
- if (/buildTypes\s*{[\s\S]*?release\s*{/.test(updatedGradleContent)) {
301
- updatedGradleContent = updatedGradleContent.replace(
302
- /(buildTypes\s*{[\s\S]*?release\s*{)/,
303
- '$1\n minifyEnabled true'
304
- );
305
- console.log('✅ Inserted minifyEnabled true into release block.');
306
- } else {
307
- console.log('⚠️ Warning: buildTypes > release block not found. minifyEnabled was not added.');
308
- }
309
- } else {
310
- console.log('ℹ️ minifyEnabled true already present. No change needed.');
311
- }
312
-
313
-
314
-
315
-
316
-
317
-
318
- // Write the updated gradle content back to build.gradle
319
- fs.writeFileSync(gradleFilePath, updatedGradleContent, 'utf8');
320
- console.log(`✅ Updated build.gradle with versionCode: ${finalVersionCode}, versionName: ${finalVersionName}, resConfigs "en" and "minifyEnabled true"`);
321
-
322
- storeIds.forEach((id) => {
323
- console.log(`ℹ️ Building for Store ID ${id}`);
324
-
325
- // Set the environment variable for store ID
326
- process.env.VITE_STORE_ID = id;
327
-
328
- // Conditionally set the new file name
329
- let newFileName;
330
- let storeName = storeNames[id];
331
-
332
- managePackages(storeName);
333
-
334
- if (storeName === "SamsungStore") {
335
- // For SamsungStore, rename to versionCode value only
336
- newFileName = `${finalVersionCode}.aab`;
337
- } else {
338
- // For other stores, use the standard naming format
339
- newFileName = `app-release-signed-${storeName}-b${finalVersionCode}-v${finalVersionName}.aab`;
340
- }
341
-
342
- //storeName="amazon"
343
- const checkFullPath = path.join("AAB", newFileName); // Update to point to the new AAB directory
344
-
345
- // Modify minSdkVersion in variables.gradle for SamsungStore
346
- const variablesGradleFilePath = path.join("android", "variables.gradle");
347
- let variablesGradleContent = fs.readFileSync(variablesGradleFilePath, 'utf8');
348
-
349
- // Extract the current minSdkVersion
350
- const minSdkVersionMatch = variablesGradleContent.match(/minSdkVersion\s*=\s*(\d+)/);
351
- const currentMinSdkVersion = minSdkVersionMatch ? parseInt(minSdkVersionMatch[1], 10) : null;
352
-
353
- // Store the original minSdkVersion (only on the first iteration)
354
- if (!originalMinSdkVersion) {
355
- originalMinSdkVersion = currentMinSdkVersion;
356
- }
357
- try {
358
- // Modify the minSdkVersion based on the store
359
- if (storeName === "SamsungStore" || storeName === "PlayStore") {
360
- if (currentMinSdkVersion !== 24) {
361
- variablesGradleContent = variablesGradleContent.replace(/minSdkVersion\s*=\s*\d+/, 'minSdkVersion = 24');
362
- console.log('minSdkVersion updated to 24 for SamsungStore & PlayStore');
363
- fs.writeFileSync(variablesGradleFilePath, variablesGradleContent);
364
- }
365
- } else {
366
- // For PlayStore and AmazonStore, ensure minSdkVersion is originalMinSdkVersion
367
- //if (currentMinSdkVersion !== originalMinSdkVersion) {
368
- variablesGradleContent = variablesGradleContent.replace(/minSdkVersion\s*=\s*\d+/, `minSdkVersion = ${amazonMinSdkVersion}`);
369
- console.log(`minSdkVersion reverted to ${amazonMinSdkVersion} for ${storeName}`);
370
- fs.writeFileSync(variablesGradleFilePath, variablesGradleContent);
371
- //}
372
- }
373
-
374
-
375
-
376
- // Run the Node.js script to modify plugin.xml
377
- if (isAdmobFound) {
378
- child_process.execSync('node buildCodeplay/modify-plugin-xml.js', { stdio: 'inherit' });
379
- } else {
380
- console.log("\x1b[33m%s\x1b[0m", "Seems to Pro Version [No ads found]");
381
- }
382
-
383
- // Run the Vite build
384
- child_process.execSync(`npm run build:storeid${id}`, { stdio: 'inherit' });
385
-
386
-
387
-
388
- // Copy the built files to the appropriate folder
389
- const src = path.join("www", "*");
390
- const dest = path.join("android", "app", "src", "main", "assets", "public");
391
-
392
- // Use 'xcopy' command for Windows
393
- child_process.execSync(`xcopy ${src} ${dest} /E /I /Y`, { stdio: 'inherit' });
394
-
395
- // Build Android AAB file
396
- //child_process.execSync('cd android && ./gradlew bundleRelease', { stdio: 'inherit' });
397
-
398
-
399
- // Build Android AAB file with Capacitor
400
- child_process.execSync('npx cap sync android', { stdio: 'inherit' });
401
- child_process.execSync('npx cap build android --androidreleasetype=AAB', { stdio: 'inherit' });
402
-
403
-
404
-
405
- variablesGradleContent = variablesGradleContent.replace(/minSdkVersion\s*=\s*\d+/, 'minSdkVersion = 24');
406
- console.log('minSdkVersion revert to 24 (default)');
407
- fs.writeFileSync(variablesGradleFilePath, variablesGradleContent);
408
-
409
-
410
- // Rename the output AAB file
411
- const oldFilePath = path.join(aabDirectory, "app-release-signed.aab");
412
- if (fs.existsSync(oldFilePath)) {
413
- fs.renameSync(oldFilePath, checkFullPath);
414
- console.log(`✅ Renamed output AAB file to: ${newFileName}`);
415
- } else {
416
- console.error("❌ AAB file not found after build.");
417
- }
418
-
419
- } catch (error) {
420
- console.error(`❌ Error during build for Store ID ${id}:`, error);
421
- process.exit(1);
422
- }
423
- });
424
-
425
- rl.close(); // Close the readline interface after all operations
426
- });
427
- });
428
-
429
-
430
-
431
-
432
-
433
- function managePackages(store) {
434
- console.log(`IAP Configurations - PlayStore: ${playstore}, Samsung: ${samsung}, Amazon: ${amazon}`);
435
-
436
- let install = "";
437
- let uninstall = "";
438
-
439
-
440
-
441
- let manifestContent = fs.readFileSync(androidManifestPath, 'utf-8');
442
-
443
- const permissionsToRemove = [
444
- 'com.android.vending.BILLING',
445
- 'com.samsung.android.iap.permission.BILLING'
446
- ];
447
-
448
-
449
- permissionsToRemove.forEach(permission => {
450
- const permissionRegex = new RegExp(`^\\s*<uses-permission\\s+android:name="${permission}"\\s*/?>\\s*[\r\n]?`, 'm');
451
- if (permissionRegex.test(manifestContent)) {
452
- manifestContent = manifestContent.replace(permissionRegex, '');
453
- console.log(`✅ Removed <uses-permission android:name="${permission}" /> from AndroidManifest.xml`);
454
- }
455
- });
456
-
457
- // Write the updated content back to the file
458
- fs.writeFileSync(androidManifestPath, manifestContent, 'utf-8');
459
-
460
-
461
-
462
- if ((playstore && store === "PlayStore") || (amazon && store === "AmazonStore")) {
463
- install = '@revenuecat/purchases-capacitor';
464
- uninstall = 'cordova-plugin-samsungiap';
465
-
466
- // Update AndroidManifest.xml for PlayStore
467
- if(playstore)
468
- updateAndroidManifest(store,
469
- '<uses-permission android:name="com.android.vending.BILLING" />');
470
-
471
- } else if (samsung && store === "SamsungStore") {
472
- install = 'cordova-plugin-samsungiap';
473
- uninstall = '@revenuecat/purchases-capacitor';
474
-
475
- // Update AndroidManifest.xml for SamsungStore
476
- updateAndroidManifest(store,
477
- '<uses-permission android:name="com.samsung.android.iap.permission.BILLING" />');
478
-
479
- } else {
480
- console.log("No valid store specified or no configurations found. Both plugins will be uninstalled.");
481
- try {
482
- child_process.execSync(`npm uninstall cordova-plugin-samsungiap`, { stdio: 'inherit' });
483
- child_process.execSync(`npm uninstall @revenuecat/purchases-capacitor`, { stdio: 'inherit' });
484
- console.log(`✅ Both plugins uninstalled successfully.`);
485
- } catch (err) {
486
- console.error("❌ Error uninstalling plugins:", err);
487
- }
488
- return;
489
- }
490
-
491
- console.log(`⚠️ Installing ${install} and uninstalling ${uninstall} for ${store}...`);
492
- try {
493
- if (install) {
494
- child_process.execSync(`npm install ${install}`, { stdio: 'inherit' });
495
- }
496
- if (uninstall) {
497
- child_process.execSync(`npm uninstall ${uninstall}`, { stdio: 'inherit' });
498
- }
499
- console.log(`✅ ${install} installed and ${uninstall} uninstalled successfully.`);
500
- } catch (err) {
501
- console.error(`❌ Error managing packages for ${store}:`, err);
502
- }
503
- }
504
-
505
-
506
-
507
- function updateAndroidManifest(store, addPermission) {
508
- try {
509
- if (!fs.existsSync(androidManifestPath)) {
510
- console.error("❌ AndroidManifest.xml file not found!");
511
- return;
512
- }
513
-
514
- // Read the content of the AndroidManifest.xml
515
- let manifestContent = fs.readFileSync(androidManifestPath, 'utf-8');
516
-
517
- // Normalize line endings to `\n` for consistent processing
518
- manifestContent = manifestContent.replace(/\r\n/g, '\n');
519
-
520
- // Check if the permission is already present
521
- if (manifestContent.includes(addPermission.trim())) {
522
- console.log(`${addPermission} is already in the AndroidManifest.xml. Skipping addition.`);
523
- return; // Skip if the permission is already present
524
- }
525
-
526
- // Insert the permission before the closing </manifest> tag
527
- const closingTag = '</manifest>';
528
- const formattedPermission = ` ${addPermission.trim()}\n`;
529
- if (manifestContent.includes(closingTag)) {
530
- manifestContent = manifestContent.replace(
531
- closingTag,
532
- `${formattedPermission}${closingTag}`
533
- );
534
- console.log(`✅ Added ${addPermission} before </manifest> tag.`);
535
- } else {
536
- console.warn(`⚠️ </manifest> tag not found. Adding ${addPermission} at the end of the file.`);
537
- manifestContent += `\n${formattedPermission}`;
538
- }
539
-
540
- // Normalize line endings back to `\r\n` and write the updated content
541
- manifestContent = manifestContent.replace(/\n/g, '\r\n');
542
- fs.writeFileSync(androidManifestPath, manifestContent, 'utf-8');
543
- console.log(`✅ AndroidManifest.xml updated successfully for ${store}`);
544
- } catch (err) {
545
- console.error(`❌ Error updating AndroidManifest.xml for ${store}:`, err);
546
- }
547
- }
548
-
549
-
550
-
551
- /* function updateAndroidManifest1(store, addPermission) {
552
- try {
553
- if (!fs.existsSync(androidManifestPath)) {
554
- console.error("AndroidManifest.xml file not found!");
555
- return;
556
- }
557
-
558
- let manifestContent = fs.readFileSync(androidManifestPath, 'utf-8');
559
-
560
-
561
-
562
- // Add the required permission if not already present
563
- if (!manifestContent.includes(addPermission)) {
564
- const manifestLines = manifestContent.split('\n');
565
- const insertIndex = manifestLines.findIndex(line => line.trim().startsWith('<application'));
566
- if (insertIndex > -1) {
567
- manifestLines.splice(insertIndex, 0, ` ${addPermission}`);
568
- manifestContent = manifestLines.join('\n');
569
- console.log(`Added ${addPermission} to AndroidManifest.xml`);
570
- }
571
- }
572
-
573
- // Write the updated content back to the file
574
- fs.writeFileSync(androidManifestPath, manifestContent, 'utf-8');
575
- console.log(`AndroidManifest.xml updated successfully for ${store}`);
576
- } catch (err) {
577
- console.error(`Error updating AndroidManifest.xml for ${store}:`, err);
578
- }
579
- } */
580
-
581
-
582
-
583
-
584
-
585
-
586
-
587
-