@jetstart/core 2.3.2 → 2.3.4

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.
@@ -52,14 +52,21 @@ class DexGenerator {
52
52
  async findD8() {
53
53
  if (this.d8Path)
54
54
  return this.d8Path;
55
- // Check multiple locations for Android SDK
56
- let androidHome = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;
57
- // Fallback to common Windows locations
55
+ // Check environment variables first, but validate the path actually exists
56
+ const envAndroidHome = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;
57
+ let androidHome;
58
+ if (envAndroidHome && fs.existsSync(path.join(envAndroidHome, 'build-tools'))) {
59
+ androidHome = envAndroidHome;
60
+ }
61
+ // Fallback: probe common install locations
58
62
  if (!androidHome) {
59
63
  const commonLocations = [
60
- 'C:\\Android',
61
64
  path.join(os.homedir(), 'AppData', 'Local', 'Android', 'Sdk'),
65
+ 'C:\\Android',
62
66
  'C:\\Users\\Public\\Android\\Sdk',
67
+ path.join(os.homedir(), 'Android', 'Sdk'),
68
+ path.join(os.homedir(), 'Library', 'Android', 'sdk'),
69
+ '/opt/android-sdk',
63
70
  ];
64
71
  for (const loc of commonLocations) {
65
72
  if (fs.existsSync(path.join(loc, 'build-tools'))) {
@@ -70,7 +77,7 @@ class DexGenerator {
70
77
  }
71
78
  }
72
79
  if (!androidHome) {
73
- (0, logger_1.error)('ANDROID_HOME or ANDROID_SDK_ROOT not set');
80
+ (0, logger_1.error)('Android build-tools not found');
74
81
  return null;
75
82
  }
76
83
  // d8 is in build-tools
@@ -140,11 +140,22 @@ class KotlinCompiler {
140
140
  catch { /* permission / access errors — silently skip */ }
141
141
  return null;
142
142
  };
143
+ const homeDir = os.homedir();
144
+ // JetStart installs kotlinc here when the user runs --full-install
145
+ const jetstartKotlinc = win
146
+ ? path.join(homeDir, '.jetstart', 'kotlinc', 'bin', 'kotlinc.bat')
147
+ : path.join(homeDir, '.jetstart', 'kotlinc', 'bin', 'kotlinc');
148
+ // Validate KOTLIN_HOME if set — only use it when it actually points to kotlinc
149
+ const kotlinHomeCandidate = process.env.KOTLIN_HOME
150
+ ? (win
151
+ ? path.join(process.env.KOTLIN_HOME, 'bin', 'kotlinc.bat')
152
+ : path.join(process.env.KOTLIN_HOME, 'bin', 'kotlinc'))
153
+ : null;
143
154
  const locations = [
144
- // env overrides
145
- process.env.KOTLIN_HOME
146
- ? path.join(process.env.KOTLIN_HOME, 'bin', 'kotlinc')
147
- : null,
155
+ // JetStart managed install (~/.jetstart/kotlinc) — checked first
156
+ jetstartKotlinc,
157
+ // env overrides (validated)
158
+ kotlinHomeCandidate,
148
159
  process.env.ANDROID_STUDIO_HOME
149
160
  ? path.join(process.env.ANDROID_STUDIO_HOME, 'plugins', 'Kotlin', 'kotlinc', 'bin', 'kotlinc')
150
161
  : null,
@@ -152,7 +163,7 @@ class KotlinCompiler {
152
163
  win ? path.join(progFiles, 'kotlinc', 'bin', 'kotlinc.bat') : null,
153
164
  win ? 'C:\\kotlinc\\bin\\kotlinc.bat' : null,
154
165
  // Scoop (~\scoop\apps\kotlin\current)
155
- win ? path.join(os.homedir(), 'scoop', 'apps', 'kotlin', 'current', 'bin', 'kotlinc.bat') : null,
166
+ win ? path.join(homeDir, 'scoop', 'apps', 'kotlin', 'current', 'bin', 'kotlinc.bat') : null,
156
167
  // Chocolatey
157
168
  win ? 'C:\\ProgramData\\chocolatey\\bin\\kotlinc.bat' : null,
158
169
  // Android Studio — standard Google installer
@@ -174,11 +185,11 @@ class KotlinCompiler {
174
185
  !win ? '/opt/homebrew/bin/kotlinc' : null,
175
186
  !win ? '/usr/local/opt/kotlin/bin/kotlinc' : null,
176
187
  // SDKMAN (~/.sdkman/candidates/kotlin/current)
177
- !win ? path.join(os.homedir(), '.sdkman', 'candidates', 'kotlin', 'current', 'bin', 'kotlinc') : null,
188
+ !win ? path.join(homeDir, '.sdkman', 'candidates', 'kotlin', 'current', 'bin', 'kotlinc') : null,
178
189
  // Snap
179
190
  !win ? '/snap/bin/kotlinc' : null,
180
191
  // IntelliJ IDEA — Linux Toolbox
181
- !win ? findInVersionedDir(path.join(os.homedir(), '.local', 'share', 'JetBrains', 'Toolbox', 'apps', 'IDEA-U', 'ch-0'), '', 'plugins', 'Kotlin', 'kotlinc', 'bin', 'kotlinc') : null,
192
+ !win ? findInVersionedDir(path.join(homeDir, '.local', 'share', 'JetBrains', 'Toolbox', 'apps', 'IDEA-U', 'ch-0'), '', 'plugins', 'Kotlin', 'kotlinc', 'bin', 'kotlinc') : null,
182
193
  ];
183
194
  for (const loc of locations) {
184
195
  if (!loc)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetstart/core",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "Build server and orchestration for JetStart",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -33,8 +33,8 @@
33
33
  },
34
34
  "homepage": "https://github.com/dev-phantom/jetstart#readme",
35
35
  "dependencies": {
36
- "@jetstart/shared": "^2.3.2",
37
- "@jetstart/logs": "^2.3.2",
36
+ "@jetstart/shared": "^2.3.4",
37
+ "@jetstart/logs": "^2.3.4",
38
38
  "express": "^4.18.2",
39
39
  "ws": "^8.14.2",
40
40
  "chokidar": "^3.5.3",
@@ -26,15 +26,22 @@ export class DexGenerator {
26
26
  async findD8(): Promise<string | null> {
27
27
  if (this.d8Path) return this.d8Path;
28
28
 
29
- // Check multiple locations for Android SDK
30
- let androidHome = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;
29
+ // Check environment variables first, but validate the path actually exists
30
+ const envAndroidHome = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;
31
+ let androidHome: string | undefined;
32
+ if (envAndroidHome && fs.existsSync(path.join(envAndroidHome, 'build-tools'))) {
33
+ androidHome = envAndroidHome;
34
+ }
31
35
 
32
- // Fallback to common Windows locations
36
+ // Fallback: probe common install locations
33
37
  if (!androidHome) {
34
38
  const commonLocations = [
35
- 'C:\\Android',
36
39
  path.join(os.homedir(), 'AppData', 'Local', 'Android', 'Sdk'),
40
+ 'C:\\Android',
37
41
  'C:\\Users\\Public\\Android\\Sdk',
42
+ path.join(os.homedir(), 'Android', 'Sdk'),
43
+ path.join(os.homedir(), 'Library', 'Android', 'sdk'),
44
+ '/opt/android-sdk',
38
45
  ];
39
46
  for (const loc of commonLocations) {
40
47
  if (fs.existsSync(path.join(loc, 'build-tools'))) {
@@ -46,7 +53,7 @@ export class DexGenerator {
46
53
  }
47
54
 
48
55
  if (!androidHome) {
49
- logError('ANDROID_HOME or ANDROID_SDK_ROOT not set');
56
+ logError('Android build-tools not found');
50
57
  return null;
51
58
  }
52
59
 
@@ -123,11 +123,25 @@ export class KotlinCompiler {
123
123
  return null;
124
124
  };
125
125
 
126
+ const homeDir = os.homedir();
127
+ // JetStart installs kotlinc here when the user runs --full-install
128
+ const jetstartKotlinc = win
129
+ ? path.join(homeDir, '.jetstart', 'kotlinc', 'bin', 'kotlinc.bat')
130
+ : path.join(homeDir, '.jetstart', 'kotlinc', 'bin', 'kotlinc');
131
+
132
+ // Validate KOTLIN_HOME if set — only use it when it actually points to kotlinc
133
+ const kotlinHomeCandidate = process.env.KOTLIN_HOME
134
+ ? (win
135
+ ? path.join(process.env.KOTLIN_HOME, 'bin', 'kotlinc.bat')
136
+ : path.join(process.env.KOTLIN_HOME, 'bin', 'kotlinc'))
137
+ : null;
138
+
126
139
  const locations: Array<string | null> = [
127
- // env overrides
128
- process.env.KOTLIN_HOME
129
- ? path.join(process.env.KOTLIN_HOME, 'bin', 'kotlinc')
130
- : null,
140
+ // JetStart managed install (~/.jetstart/kotlinc) — checked first
141
+ jetstartKotlinc,
142
+
143
+ // env overrides (validated)
144
+ kotlinHomeCandidate,
131
145
  process.env.ANDROID_STUDIO_HOME
132
146
  ? path.join(process.env.ANDROID_STUDIO_HOME, 'plugins', 'Kotlin', 'kotlinc', 'bin', 'kotlinc')
133
147
  : null,
@@ -136,7 +150,7 @@ export class KotlinCompiler {
136
150
  win ? path.join(progFiles, 'kotlinc', 'bin', 'kotlinc.bat') : null,
137
151
  win ? 'C:\\kotlinc\\bin\\kotlinc.bat' : null,
138
152
  // Scoop (~\scoop\apps\kotlin\current)
139
- win ? path.join(os.homedir(), 'scoop', 'apps', 'kotlin', 'current', 'bin', 'kotlinc.bat') : null,
153
+ win ? path.join(homeDir, 'scoop', 'apps', 'kotlin', 'current', 'bin', 'kotlinc.bat') : null,
140
154
  // Chocolatey
141
155
  win ? 'C:\\ProgramData\\chocolatey\\bin\\kotlinc.bat' : null,
142
156
  // Android Studio — standard Google installer
@@ -164,11 +178,11 @@ export class KotlinCompiler {
164
178
  !win ? '/opt/homebrew/bin/kotlinc' : null,
165
179
  !win ? '/usr/local/opt/kotlin/bin/kotlinc' : null,
166
180
  // SDKMAN (~/.sdkman/candidates/kotlin/current)
167
- !win ? path.join(os.homedir(), '.sdkman', 'candidates', 'kotlin', 'current', 'bin', 'kotlinc') : null,
181
+ !win ? path.join(homeDir, '.sdkman', 'candidates', 'kotlin', 'current', 'bin', 'kotlinc') : null,
168
182
  // Snap
169
183
  !win ? '/snap/bin/kotlinc' : null,
170
184
  // IntelliJ IDEA — Linux Toolbox
171
- !win ? findInVersionedDir(path.join(os.homedir(), '.local', 'share', 'JetBrains', 'Toolbox', 'apps', 'IDEA-U', 'ch-0'), '',
185
+ !win ? findInVersionedDir(path.join(homeDir, '.local', 'share', 'JetBrains', 'Toolbox', 'apps', 'IDEA-U', 'ch-0'), '',
172
186
  'plugins', 'Kotlin', 'kotlinc', 'bin', 'kotlinc') : null,
173
187
  ];
174
188