vaderjs-native 1.0.0 → 1.0.1

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/main.js +40 -2
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -6,10 +6,47 @@ import fs from "fs/promises";
6
6
  import fsSync from "fs";
7
7
  import path from "path";
8
8
  import { init } from "./cli";
9
-
9
+ import os from "os";
10
+ import { execSync } from "child_process";
11
+ import { existsSync, writeFileSync } from "fs";
10
12
  // --- UTILITIES for a Sleek CLI ---
11
13
 
12
-
14
+ async function ensureLocalProperties() {
15
+ const ROOT = path.join(
16
+ PROJECT_ROOT,
17
+ "node_modules",
18
+ "vaderjs-native",
19
+ "app-template"
20
+ );
21
+
22
+ const localPropsPath = path.join(ROOT, "local.properties");
23
+ if (fsSync.existsSync(localPropsPath)) return;
24
+
25
+ // Determine SDK path
26
+ let sdkPath = process.env.ANDROID_HOME;
27
+
28
+ if (!sdkPath) {
29
+ const home = os.homedir();
30
+ if (process.platform === "win32") {
31
+ sdkPath = path.join(home, "AppData", "Local", "Android", "Sdk");
32
+ } else if (process.platform === "darwin") {
33
+ sdkPath = path.join(home, "Library", "Android", "sdk");
34
+ } else {
35
+ // Linux
36
+ sdkPath = path.join(home, "Android", "Sdk");
37
+ }
38
+ }
39
+
40
+ if (!existsSync(sdkPath)) {
41
+ throw new Error(
42
+ `Android SDK not found! Please set ANDROID_HOME or install the SDK at: ${sdkPath}`
43
+ );
44
+ }
45
+
46
+ const content = `sdk.dir=${sdkPath.replace(/\\/g, "\\\\")}\n`;
47
+ writeFileSync(localPropsPath, content);
48
+ logger.success(`Created local.properties with sdk.dir=${sdkPath}`);
49
+ }
13
50
 
14
51
  async function copyCompiledJavascriptToJava(isDev = false) {
15
52
  if (isDev) return;
@@ -40,6 +77,7 @@ async function copyCompiledJavascriptToJava(isDev = false) {
40
77
 
41
78
  import { spawnSync } from "child_process";
42
79
  async function buildAPK() {
80
+ await ensureLocalProperties();
43
81
  const ROOT = path.join(
44
82
  PROJECT_ROOT,
45
83
  "node_modules",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs-native",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Build Android Applications using Vaderjs framework.",
5
5
  "bin": {
6
6
  "vaderjs": "./main.js"