codeplay-common 3.0.3 → 3.0.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.
@@ -0,0 +1,92 @@
1
+ const { spawn } = require("child_process");
2
+ const path = require("path");
3
+ const fs = require("fs");
4
+
5
+ // Paths
6
+ //const projectRoot = path.join(__dirname, "..");
7
+ const projectRoot = process.cwd();
8
+ const androidPath = path.join(projectRoot, "android");
9
+ const capacitorConfigPath = path.join(projectRoot, "capacitor.config.json");
10
+
11
+ // Read capacitor.config.json
12
+ if (!fs.existsSync(capacitorConfigPath)) {
13
+ console.error("❌ capacitor.config.json not found!");
14
+ process.exit(1);
15
+ }
16
+
17
+ const config = JSON.parse(fs.readFileSync(capacitorConfigPath, "utf8"));
18
+
19
+ const buildOptions = config.android?.buildOptions;
20
+
21
+ if (!buildOptions) {
22
+ console.error("❌ android.buildOptions not found in capacitor.config.json");
23
+ process.exit(1);
24
+ }
25
+
26
+ // Resolve keystore path (relative → absolute)
27
+
28
+
29
+ const storePassword = buildOptions.keystorePassword;
30
+ const keyAlias = buildOptions.keystoreAlias;
31
+ const keyPassword = buildOptions.keystoreAliasPassword;
32
+
33
+
34
+
35
+
36
+
37
+
38
+ const rawKeystorePath = buildOptions.keystorePath;
39
+
40
+ // First try normal resolve
41
+ let keystorePath = path.resolve(projectRoot, rawKeystorePath);
42
+
43
+ // If not found, try trimming one "../"
44
+ if (!fs.existsSync(keystorePath)) {
45
+ console.log("⚠️ Keystore not found, attempting path correction...");
46
+
47
+ const trimmedPath = rawKeystorePath.replace(/^\.\.\//, "");
48
+ keystorePath = path.resolve(projectRoot, trimmedPath);
49
+ }
50
+
51
+ // Final validation
52
+ if (!fs.existsSync(keystorePath)) {
53
+ console.error("❌ Keystore file not found even after correction:", keystorePath);
54
+ process.exit(1);
55
+ }
56
+
57
+ console.log("🔐 Using keystore:", keystorePath);
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+ // Gradle args
69
+ const args = [
70
+ "/c",
71
+ "gradlew.bat",
72
+ "assembleRelease",
73
+ `-Pandroid.injected.signing.store.file=${keystorePath}`,
74
+ `-Pandroid.injected.signing.store.password=${storePassword}`,
75
+ `-Pandroid.injected.signing.key.alias=${keyAlias}`,
76
+ `-Pandroid.injected.signing.key.password=${keyPassword}`,
77
+ ];
78
+
79
+ // Run Gradle
80
+ const gradle = spawn("cmd.exe", args, {
81
+ cwd: androidPath,
82
+ stdio: "inherit",
83
+ });
84
+
85
+ gradle.on("close", (code) => {
86
+ if (code === 0) {
87
+ console.log("\n✅ Signed APK Generated Successfully!");
88
+ } else {
89
+ console.log("\n❌ Build Failed with code:", code);
90
+ process.exit(code);
91
+ }
92
+ });
@@ -22,7 +22,7 @@ const requiredPlugins = [
22
22
  { pattern: /localNotification_AppSettings-(\d+\.\d+)\.js$/, minVersion: '1.0', required: true, baseDir: 'js',mandatoryUpdate: false },
23
23
  { pattern: /onesignal-(\d+\.\d+)\.js$/, minVersion: '2.3', required: true, baseDir: 'js',mandatoryUpdate: false },
24
24
  { pattern: /saveToGalleryAndSaveAnyFile-(\d+\.\d+)(-ios)?\.js$/, minVersion: '3.1', required: true, baseDir: 'js',mandatoryUpdate: true },
25
- { pattern: /Ads[\/\\]admob-emi-(\d+\.\d+)\.js$/, minVersion: '3.6', required: true, baseDir: 'js',mandatoryUpdate: true },
25
+ { pattern: /Ads[\/\\]admob-emi-(\d+\.\d+)\.js$/, minVersion: '3.7', required: true, baseDir: 'js',mandatoryUpdate: true },
26
26
 
27
27
  // New added plugins
28
28
  { pattern: /video-player-(\d+\.\d+)\.js$/, minVersion: '1.5', required: true, baseDir: 'js',mandatoryUpdate: false },
@@ -390,7 +390,7 @@ function writeCapacitorConfig(config) {
390
390
  fs.writeFileSync(capacitorConfigPath, JSON.stringify(config, null, 2), 'utf8');
391
391
  }
392
392
 
393
- function updateCapacitorConfig(releaseType, signingType) {
393
+ /* function updateCapacitorConfig(releaseType, signingType) {
394
394
  const config = readCapacitorConfig();
395
395
 
396
396
  // Save original values once
@@ -405,9 +405,9 @@ function updateCapacitorConfig(releaseType, signingType) {
405
405
 
406
406
  writeCapacitorConfig(config);
407
407
  console.log(`ℹ️ capacitor.config.json updated: releaseType=${releaseType}, signingType=${signingType}`);
408
- }
408
+ } */
409
409
 
410
- function restoreCapacitorConfig() {
410
+ /* function restoreCapacitorConfig() {
411
411
  const config = readCapacitorConfig();
412
412
  if (originalReleaseType !== undefined) config.android.buildOptions.releaseType = originalReleaseType;
413
413
  if (originalSigningType !== undefined) config.android.buildOptions.signingType = originalSigningType;
@@ -423,7 +423,7 @@ process.on('SIGINT', () => {
423
423
 
424
424
  process.on('exit', () => {
425
425
  restoreCapacitorConfig();
426
- });
426
+ }); */
427
427
 
428
428
 
429
429
 
@@ -690,20 +690,33 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
690
690
  let buildType = ["VivoStore","OppoStore","MiStore"].includes(storeName) ? "APK" : "AAB";
691
691
  let signingType = buildType === "APK" ? "apksigner" : "jarsigner";
692
692
 
693
- // Update capacitor.config.json for this store
694
- updateCapacitorConfig(buildType, signingType);
693
+ // Update capacitor.config.json for this store - This is not needed
694
+ //updateCapacitorConfig(buildType, signingType);
695
695
 
696
696
 
697
697
 
698
+ /* execSync('npx cap sync android', { stdio: 'inherit' });
699
+ execSync(`npx cap build android --androidreleasetype=${buildType}`, { stdio: 'inherit' }); */
700
+
701
+
698
702
  execSync('npx cap sync android', { stdio: 'inherit' });
699
- execSync(`npx cap build android --androidreleasetype=${buildType}`, { stdio: 'inherit' });
703
+
704
+ if (buildType === "APK") {
705
+ console.log("📦 Using custom Node signing script for APK build...");
706
+ execSync('node buildCodeplay/apk-store-builder.js', { stdio: 'inherit' });
707
+ } else {
708
+ execSync(`npx cap build android --androidreleasetype=${buildType}`, { stdio: 'inherit' });
709
+ }
710
+
711
+
700
712
 
701
713
  // Determine output paths
702
714
  let oldFilePath;
703
715
  let newExt = buildType === "APK" ? "apk" : "aab";
704
716
 
705
717
  if (buildType === "APK") {
706
- oldFilePath = join("android", "app", "build", "outputs", "apk", "release", "app-release-signed.apk");
718
+ //oldFilePath = join("android", "app", "build", "outputs", "apk", "release", "app-release-signed.apk");
719
+ oldFilePath = join("android", "app", "build", "outputs", "apk", "release", "app-release.apk");
707
720
  } else {
708
721
  oldFilePath = join("android", "app", "build", "outputs", "bundle", "release", "app-release-signed.aab");
709
722
  }
@@ -848,8 +861,8 @@ function updateAndroidManifest(store, addPermission) {
848
861
  }
849
862
  }
850
863
 
851
- restoreCapacitorConfig();
852
- console.log("🏁 All builds completed, capacitor.config.json restored.");
864
+ /* restoreCapacitorConfig();
865
+ console.log("🏁 All builds completed, capacitor.config.json restored."); */
853
866
 
854
867
 
855
868
  /* function updateAndroidManifest1(store, addPermission) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",