codeplay-common 2.1.50 → 2.1.51

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.
@@ -1359,6 +1359,39 @@ validateThemeFolderLocation()
1359
1359
 
1360
1360
 
1361
1361
 
1362
+ const validateAndRestoreSignDetails=()=>{
1363
+
1364
+ // Read config file
1365
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
1366
+
1367
+ // Ensure android and buildOptions exist
1368
+ if (!config.android) config.android = {};
1369
+ if (!config.android.buildOptions) config.android.buildOptions = {};
1370
+
1371
+ // Update only if changed
1372
+ let updated = false;
1373
+
1374
+ if (config.android.buildOptions.releaseType !== 'AAB') {
1375
+ config.android.buildOptions.releaseType = 'AAB';
1376
+ updated = true;
1377
+ }
1378
+
1379
+ if (config.android.buildOptions.signingType !== 'jarsigner') {
1380
+ config.android.buildOptions.signingType = 'jarsigner';
1381
+ updated = true;
1382
+ }
1383
+
1384
+ // Write back only if modified
1385
+ if (updated) {
1386
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
1387
+ console.log('capacitor.config.json updated successfully.');
1388
+ } else {
1389
+ console.log('No changes needed.');
1390
+ }
1391
+
1392
+ }
1393
+
1394
+ validateAndRestoreSignDetails()
1362
1395
 
1363
1396
 
1364
1397
  /*
@@ -380,6 +380,50 @@ if (_isADMOB_ENABLED)
380
380
 
381
381
 
382
382
 
383
+ let originalReleaseType, originalSigningType;
384
+
385
+ function readCapacitorConfig() {
386
+ return JSON.parse(fs.readFileSync(capacitorConfigPath, 'utf8'));
387
+ }
388
+
389
+ function writeCapacitorConfig(config) {
390
+ fs.writeFileSync(capacitorConfigPath, JSON.stringify(config, null, 2), 'utf8');
391
+ }
392
+
393
+ function updateCapacitorConfig(releaseType, signingType) {
394
+ const config = readCapacitorConfig();
395
+
396
+ // Save original values once
397
+ if (originalReleaseType === undefined) originalReleaseType = config.android?.buildOptions?.releaseType || '';
398
+ if (originalSigningType === undefined) originalSigningType = config.android?.buildOptions?.signingType || '';
399
+
400
+ // Update values
401
+ config.android = config.android || {};
402
+ config.android.buildOptions = config.android.buildOptions || {};
403
+ config.android.buildOptions.releaseType = releaseType;
404
+ config.android.buildOptions.signingType = signingType;
405
+
406
+ writeCapacitorConfig(config);
407
+ console.log(`ℹ️ capacitor.config.json updated: releaseType=${releaseType}, signingType=${signingType}`);
408
+ }
409
+
410
+ function restoreCapacitorConfig() {
411
+ const config = readCapacitorConfig();
412
+ if (originalReleaseType !== undefined) config.android.buildOptions.releaseType = originalReleaseType;
413
+ if (originalSigningType !== undefined) config.android.buildOptions.signingType = originalSigningType;
414
+ writeCapacitorConfig(config);
415
+ console.log(`✅ capacitor.config.json restored to original values.`);
416
+ }
417
+
418
+ process.on('SIGINT', () => {
419
+ console.log('\n⚠️ Detected Ctrl+C, restoring capacitor.config.json...');
420
+ restoreCapacitorConfig();
421
+ process.exit(0);
422
+ });
423
+
424
+ process.on('exit', () => {
425
+ restoreCapacitorConfig();
426
+ });
383
427
 
384
428
 
385
429
 
@@ -636,10 +680,20 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
636
680
  // Build Android AAB or APK file based on store
637
681
  console.log(`🏗️ Building release for ${storeName}...`);
638
682
 
639
- let buildType = "AAB";
683
+ /* let buildType = "AAB";
640
684
  if (["VivoStore", "OppoStore", "MiStore"].includes(storeName)) {
641
685
  buildType = "APK";
642
- }
686
+ } */
687
+
688
+
689
+ // Determine build type and signing type per store
690
+ let buildType = ["VivoStore","OppoStore","MiStore"].includes(storeName) ? "APK" : "AAB";
691
+ let signingType = buildType === "APK" ? "apksigner" : "jarsigner";
692
+
693
+ // Update capacitor.config.json for this store
694
+ updateCapacitorConfig(buildType, signingType);
695
+
696
+
643
697
 
644
698
  execSync('npx cap sync android', { stdio: 'inherit' });
645
699
  execSync(`npx cap build android --androidreleasetype=${buildType}`, { stdio: 'inherit' });
@@ -794,6 +848,8 @@ function updateAndroidManifest(store, addPermission) {
794
848
  }
795
849
  }
796
850
 
851
+ restoreCapacitorConfig();
852
+ console.log("🏁 All builds completed, capacitor.config.json restored.");
797
853
 
798
854
 
799
855
  /* function updateAndroidManifest1(store, addPermission) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "2.1.50",
3
+ "version": "2.1.51",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",