codeplay-common 3.2.6 → 3.2.7

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.
@@ -1,92 +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
- }
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
92
  });