codeplay-common 3.0.4 → 3.0.6
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
|
+
});
|
package/files/finalrelease
CHANGED
|
@@ -26,6 +26,9 @@ import path from 'path';
|
|
|
26
26
|
"7": "AmazonStore"
|
|
27
27
|
}; */
|
|
28
28
|
|
|
29
|
+
|
|
30
|
+
const isOnlyOneAPK = true; // 🔥 change to false for normal behavior
|
|
31
|
+
|
|
29
32
|
const storeNames = {
|
|
30
33
|
"1": "PlayStore",
|
|
31
34
|
"2": "SamsungStore",
|
|
@@ -390,7 +393,7 @@ function writeCapacitorConfig(config) {
|
|
|
390
393
|
fs.writeFileSync(capacitorConfigPath, JSON.stringify(config, null, 2), 'utf8');
|
|
391
394
|
}
|
|
392
395
|
|
|
393
|
-
function updateCapacitorConfig(releaseType, signingType) {
|
|
396
|
+
/* function updateCapacitorConfig(releaseType, signingType) {
|
|
394
397
|
const config = readCapacitorConfig();
|
|
395
398
|
|
|
396
399
|
// Save original values once
|
|
@@ -405,9 +408,9 @@ function updateCapacitorConfig(releaseType, signingType) {
|
|
|
405
408
|
|
|
406
409
|
writeCapacitorConfig(config);
|
|
407
410
|
console.log(`ℹ️ capacitor.config.json updated: releaseType=${releaseType}, signingType=${signingType}`);
|
|
408
|
-
}
|
|
411
|
+
} */
|
|
409
412
|
|
|
410
|
-
function restoreCapacitorConfig() {
|
|
413
|
+
/* function restoreCapacitorConfig() {
|
|
411
414
|
const config = readCapacitorConfig();
|
|
412
415
|
if (originalReleaseType !== undefined) config.android.buildOptions.releaseType = originalReleaseType;
|
|
413
416
|
if (originalSigningType !== undefined) config.android.buildOptions.signingType = originalSigningType;
|
|
@@ -423,7 +426,7 @@ process.on('SIGINT', () => {
|
|
|
423
426
|
|
|
424
427
|
process.on('exit', () => {
|
|
425
428
|
restoreCapacitorConfig();
|
|
426
|
-
});
|
|
429
|
+
}); */
|
|
427
430
|
|
|
428
431
|
|
|
429
432
|
|
|
@@ -463,6 +466,12 @@ if (storeIdArg) {
|
|
|
463
466
|
}
|
|
464
467
|
|
|
465
468
|
|
|
469
|
+
// 🔥 If only one APK mode, override APK storeIds
|
|
470
|
+
/* if (isOnlyOneAPK) {
|
|
471
|
+
console.log("⚡ isOnlyOneAPK enabled → Only MiStore (3) will be used for APK build");
|
|
472
|
+
storeIds = ["3"]; // Only MiStore
|
|
473
|
+
} */
|
|
474
|
+
|
|
466
475
|
// Store the original minSdkVersion globally
|
|
467
476
|
let originalMinSdkVersion;
|
|
468
477
|
|
|
@@ -584,32 +593,40 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
|
|
|
584
593
|
process.env.VITE_STORE_ID = id;
|
|
585
594
|
|
|
586
595
|
// Conditionally set the new file name
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
debugger;
|
|
596
|
+
let newFileName;
|
|
597
|
+
let storeName = storeNames[id];
|
|
591
598
|
|
|
592
599
|
|
|
593
|
-
|
|
600
|
+
if (
|
|
601
|
+
isOnlyOneAPK &&
|
|
602
|
+
["OppoStore", "VivoStore"].includes(storeName)
|
|
603
|
+
) {
|
|
604
|
+
console.log(`⏭ Skipping ${storeName} because isOnlyOneAPK is enabled`);
|
|
605
|
+
return; // skip this iteration only
|
|
606
|
+
}
|
|
594
607
|
|
|
595
|
-
if (storeName === "SamsungStore") {
|
|
596
|
-
// For SamsungStore, rename to versionCode value only
|
|
597
|
-
//newFileName = `${finalVersionCode}.aab`;
|
|
598
|
-
newFileName=`${_appUniqueId}_${_appName.replaceAll(" ","_")}-${(storeName.toUpperCase()).replace("STORE","")}-b${finalVersionCode}-v${finalVersionName.replace(/\./g,'_')}.aab`
|
|
599
|
-
} else {
|
|
600
|
-
// For other stores, use the standard naming format
|
|
601
|
-
//newFileName = `app-release-signed-${storeName}-b${finalVersionCode}-v${finalVersionName}.aab`;
|
|
602
608
|
|
|
603
|
-
|
|
609
|
+
managePackages(storeName);
|
|
604
610
|
|
|
611
|
+
// 🔥 Only change filename logic — nothing else touched
|
|
612
|
+
if (isOnlyOneAPK && ["MiStore","OppoStore","VivoStore"].includes(storeName)) {
|
|
605
613
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
const _appName=config.appName;
|
|
609
|
-
const _appPackageId=config.appId;
|
|
610
|
-
*/
|
|
614
|
+
newFileName =
|
|
615
|
+
`${_appUniqueId}_${_appName.replaceAll(" ","_")}-VI_MI_OPPO-b${finalVersionCode}-v${finalVersionName.replace(/\./g,'_')}.aab`;
|
|
611
616
|
|
|
612
|
-
|
|
617
|
+
}
|
|
618
|
+
else if (storeName === "SamsungStore") {
|
|
619
|
+
|
|
620
|
+
newFileName =
|
|
621
|
+
`${_appUniqueId}_${_appName.replaceAll(" ","_")}-${(storeName.toUpperCase()).replace("STORE","")}-b${finalVersionCode}-v${finalVersionName.replace(/\./g,'_')}.aab`;
|
|
622
|
+
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
|
|
626
|
+
newFileName =
|
|
627
|
+
`${_appUniqueId}_${_appName.replaceAll(" ","_")}-${(storeName.toUpperCase()).replace("STORE","")}-b${finalVersionCode}-v${finalVersionName}.aab`;
|
|
628
|
+
|
|
629
|
+
}
|
|
613
630
|
|
|
614
631
|
//storeName="amazon"
|
|
615
632
|
const checkFullPath = join("AAB", newFileName); // Update to point to the new AAB directory
|
|
@@ -664,6 +681,9 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
|
|
|
664
681
|
// Run the Vite build
|
|
665
682
|
execSync(`npm run build:storeid${id}`, { stdio: 'inherit' });
|
|
666
683
|
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
667
687
|
|
|
668
688
|
|
|
669
689
|
// Copy the built files to the appropriate folder
|
|
@@ -690,20 +710,33 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
|
|
|
690
710
|
let buildType = ["VivoStore","OppoStore","MiStore"].includes(storeName) ? "APK" : "AAB";
|
|
691
711
|
let signingType = buildType === "APK" ? "apksigner" : "jarsigner";
|
|
692
712
|
|
|
693
|
-
// Update capacitor.config.json for this store
|
|
694
|
-
updateCapacitorConfig(buildType, signingType);
|
|
713
|
+
// Update capacitor.config.json for this store - This is not needed
|
|
714
|
+
//updateCapacitorConfig(buildType, signingType);
|
|
715
|
+
|
|
695
716
|
|
|
696
717
|
|
|
718
|
+
/* execSync('npx cap sync android', { stdio: 'inherit' });
|
|
719
|
+
execSync(`npx cap build android --androidreleasetype=${buildType}`, { stdio: 'inherit' }); */
|
|
720
|
+
|
|
697
721
|
|
|
698
722
|
execSync('npx cap sync android', { stdio: 'inherit' });
|
|
699
|
-
|
|
723
|
+
|
|
724
|
+
if (buildType === "APK") {
|
|
725
|
+
console.log("📦 Using custom Node signing script for APK build...");
|
|
726
|
+
execSync('node buildCodeplay/apk-store-builder.js', { stdio: 'inherit' });
|
|
727
|
+
} else {
|
|
728
|
+
execSync(`npx cap build android --androidreleasetype=${buildType}`, { stdio: 'inherit' });
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
|
|
700
732
|
|
|
701
733
|
// Determine output paths
|
|
702
734
|
let oldFilePath;
|
|
703
735
|
let newExt = buildType === "APK" ? "apk" : "aab";
|
|
704
736
|
|
|
705
737
|
if (buildType === "APK") {
|
|
706
|
-
oldFilePath = join("android", "app", "build", "outputs", "apk", "release", "app-release-signed.apk");
|
|
738
|
+
//oldFilePath = join("android", "app", "build", "outputs", "apk", "release", "app-release-signed.apk");
|
|
739
|
+
oldFilePath = join("android", "app", "build", "outputs", "apk", "release", "app-release.apk");
|
|
707
740
|
} else {
|
|
708
741
|
oldFilePath = join("android", "app", "build", "outputs", "bundle", "release", "app-release-signed.aab");
|
|
709
742
|
}
|
|
@@ -848,8 +881,8 @@ function updateAndroidManifest(store, addPermission) {
|
|
|
848
881
|
}
|
|
849
882
|
}
|
|
850
883
|
|
|
851
|
-
restoreCapacitorConfig();
|
|
852
|
-
console.log("🏁 All builds completed, capacitor.config.json restored.");
|
|
884
|
+
/* restoreCapacitorConfig();
|
|
885
|
+
console.log("🏁 All builds completed, capacitor.config.json restored."); */
|
|
853
886
|
|
|
854
887
|
|
|
855
888
|
/* function updateAndroidManifest1(store, addPermission) {
|