codeplay-common 1.9.3 → 1.9.5

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.
Files changed (2) hide show
  1. package/files/finalrelease +41 -19
  2. package/package.json +1 -1
@@ -43,13 +43,7 @@ const storeNames = {
43
43
 
44
44
 
45
45
 
46
-
47
- const ffmpegUsedPackages = [
48
- "vfx.green.editor",
49
- "audio.music.sound.editor",
50
- "video.to.gif.maker"
51
- ];
52
-
46
+
53
47
 
54
48
 
55
49
 
@@ -77,8 +71,24 @@ function fileExists(filePath) {
77
71
  }
78
72
 
79
73
 
74
+ const ffmpegPluginXmlPath = path.join(__dirname, 'node_modules', 'codeplay-fmpg', 'plugin.xml');
80
75
  const capacitorConfigPath = join(process.cwd(), 'capacitor.config.json');
81
76
 
77
+
78
+
79
+ function isFfmpegUsed() {
80
+ try {
81
+ const xmlContent = fs.readFileSync(ffmpegPluginXmlPath, 'utf8');
82
+ // Simple check: if plugin.xml exists and contains <plugin> tag (or any FFmpeg-specific tag)
83
+ return /<plugin\b/.test(xmlContent);
84
+ } catch (err) {
85
+ console.log('⚠️ FFmpeg plugin not found:', err.message);
86
+ return false;
87
+ }
88
+ }
89
+
90
+ const _isffmpegUsed = isFfmpegUsed();
91
+
82
92
  function getAdMobConfig() {
83
93
  if (!fileExists(capacitorConfigPath)) {
84
94
  throw new Error('❌ capacitor.config.json not found. Ensure this is a Capacitor project.');
@@ -493,7 +503,7 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
493
503
 
494
504
 
495
505
  // Determine desired minify value
496
- const desiredMinify = ffmpegUsedPackages.includes(_appPackageId) ? 'false' : 'true';
506
+ const desiredMinify = !_isffmpegUsed;
497
507
 
498
508
  // Check if minifyEnabled is already present
499
509
  if (/minifyEnabled\s+(true|false)/.test(updatedGradleContent)) {
@@ -578,7 +588,8 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
578
588
  if (storeName === "SamsungStore" || storeName === "PlayStore" ||
579
589
  //_appPackageId=="vfx.green.editor" || _appPackageId=="audio.music.sound.editor" || _appPackageId=="video.to.gif.maker"
580
590
 
581
- ffmpegUsedPackages.includes(_appPackageId)
591
+ //ffmpegUsedPackages.includes(_appPackageId)
592
+ _isffmpegUsed
582
593
  ) {
583
594
  if (currentMinSdkVersion !== 24) {
584
595
  variablesGradleContent = variablesGradleContent.replace(/minSdkVersion\s*=\s*\d+/, 'minSdkVersion = 24');
@@ -618,25 +629,36 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
618
629
  // Build Android AAB file
619
630
  //child_process.execSync('cd android && ./gradlew bundleRelease', { stdio: 'inherit' });
620
631
 
632
+
633
+ // Build Android AAB or APK file based on store
634
+ console.log(`🏗️ Building release for ${storeName}...`);
621
635
 
622
- // Build Android AAB file with Capacitor
623
- execSync('npx cap sync android', { stdio: 'inherit' });
624
- execSync('npx cap build android --androidreleasetype=AAB', { stdio: 'inherit' });
636
+ let buildType = "AAB";
637
+ if (["VivoStore", "OppoStore", "MiStore"].includes(storeName)) {
638
+ buildType = "APK";
639
+ }
625
640
 
641
+ execSync('npx cap sync android', { stdio: 'inherit' });
642
+ execSync(`npx cap build android --androidreleasetype=${buildType}`, { stdio: 'inherit' });
626
643
 
644
+ // Determine output paths
645
+ let oldFilePath;
646
+ let newExt = buildType === "APK" ? "apk" : "aab";
627
647
 
628
- variablesGradleContent = variablesGradleContent.replace(/minSdkVersion\s*=\s*\d+/, 'minSdkVersion = 24');
629
- console.log('minSdkVersion revert to 24 (default)');
630
- writeFileSync(variablesGradleFilePath, variablesGradleContent);
648
+ if (buildType === "APK") {
649
+ oldFilePath = join("android", "app", "build", "outputs", "apk", "release", "app-release-signed.apk");
650
+ } else {
651
+ oldFilePath = join("android", "app", "build", "outputs", "bundle", "release", "app-release-signed.aab");
652
+ }
631
653
 
654
+ const checkFullPath = join("AAB", newFileName.replace(/\.aab$/, `.${newExt}`));
632
655
 
633
- // Rename the output AAB file
634
- const oldFilePath = join(aabDirectory, "app-release-signed.aab");
656
+ // Rename the output file
635
657
  if (existsSync(oldFilePath)) {
636
658
  renameSync(oldFilePath, checkFullPath);
637
- console.log(`✅ Renamed output AAB file to: ${newFileName}`);
659
+ console.log(`✅ Renamed output ${newExt.toUpperCase()} file to: ${path.basename(checkFullPath)}`);
638
660
  } else {
639
- console.error("❌ AAB file not found after build.");
661
+ console.error(`❌ ${newExt.toUpperCase()} file not found after build.`);
640
662
  }
641
663
 
642
664
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "1.9.3",
3
+ "version": "1.9.5",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",