@snap/valdi 1.0.1 → 1.0.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.
Files changed (41) hide show
  1. package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +3 -3
  2. package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +18 -19
  3. package/.bootstrap/modules/cpp_bridge_module/src/Calculator.d.ts +3 -0
  4. package/.github/README.md +164 -0
  5. package/.metadata/.cursorrules.template +60 -0
  6. package/.metadata/.editorconfig.template +37 -0
  7. package/{.bootstrap/apps/ui_application → .metadata}/AGENTS.md.template +84 -4
  8. package/LINUX_COMPATIBILITY.md +248 -0
  9. package/README.md +110 -23
  10. package/dist/commands/bootstrap.js +80 -19
  11. package/dist/commands/doctor.js +361 -54
  12. package/dist/commands/newModule.js +15 -12
  13. package/dist/core/constants.js +3 -0
  14. package/dist/index.js +5 -0
  15. package/dist/setup/DevSetupHelper.js +81 -6
  16. package/dist/setup/linuxSetup.js +149 -11
  17. package/dist/setup/macOSSetup.js +96 -8
  18. package/dist/utils/githubUtils.js +74 -2
  19. package/dist/utils/linuxDistro.js +255 -0
  20. package/dist/utils/linuxDistro.spec.js +170 -0
  21. package/dist/utils/stringUtils.js +60 -0
  22. package/dist/utils/stringUtils.spec.js +63 -0
  23. package/package.json +11 -3
  24. package/scripts/sync-agents-md.sh +44 -0
  25. package/scripts/update-agents-templates.ts +170 -0
  26. package/src/commands/bootstrap.ts +118 -25
  27. package/src/commands/doctor.ts +469 -59
  28. package/src/commands/newModule.ts +18 -19
  29. package/src/core/constants.ts +3 -0
  30. package/src/index.ts +5 -0
  31. package/src/setup/DevSetupHelper.ts +108 -6
  32. package/src/setup/linuxSetup.ts +235 -12
  33. package/src/setup/macOSSetup.ts +122 -8
  34. package/src/utils/githubUtils.ts +98 -2
  35. package/src/utils/linuxDistro.spec.ts +219 -0
  36. package/src/utils/linuxDistro.ts +326 -0
  37. package/src/utils/stringUtils.spec.ts +77 -1
  38. package/src/utils/stringUtils.ts +88 -0
  39. package/test/ValdiSmokeTest.ts +5 -4
  40. package/test/helpers/TypeScriptClient.ts +2 -2
  41. package/.bootstrap/apps/cli_application/AGENTS.md.template +0 -215
@@ -44,6 +44,13 @@ import type { ArgumentsResolver } from '../utils/ArgumentsResolver';
44
44
  import { BazelClient } from '../utils/BazelClient';
45
45
  import { checkCommandExists, runCliCommand } from '../utils/cliUtils';
46
46
  import { makeCommandHandler } from '../utils/errorUtils';
47
+ import {
48
+ type LinuxDistroInfo,
49
+ buildInstallCommand,
50
+ detectLinuxDistro,
51
+ getCommonPackageMappings,
52
+ getPackageName,
53
+ } from '../utils/linuxDistro';
47
54
  import { wrapInColor } from '../utils/logUtils';
48
55
 
49
56
  /** Discord support link for troubleshooting */
@@ -114,7 +121,7 @@ interface GroupedDiagnosticResult {
114
121
  * is properly configured for Valdi development. It validates:
115
122
  * - Node.js version compatibility (≥18.0.0)
116
123
  * - Bazel build system installation and functionality (with version validation)
117
- * - Java JDK installation (Java 17+ recommended)
124
+ * - Java JDK installation (Java 17+ required)
118
125
  * - Platform-specific development tools (Android SDK, Xcode)
119
126
  * - Required development dependencies (git, npm, watchman, ios-webkit-debug-proxy)
120
127
  * - Optional project-specific checks (workspace structure)
@@ -141,6 +148,9 @@ class ValdiDoctor {
141
148
  /** Whether to include project-specific checks */
142
149
  private readonly projectMode: boolean;
143
150
 
151
+ /** Cached Linux distribution info (only on Linux) */
152
+ private readonly linuxDistro?: LinuxDistroInfo;
153
+
144
154
  /**
145
155
  * Creates a new ValdiDoctor instance.
146
156
  *
@@ -156,6 +166,11 @@ class ValdiDoctor {
156
166
  this.jsonOutput = jsonOutput;
157
167
  this.frameworkMode = frameworkMode;
158
168
  this.projectMode = projectMode;
169
+
170
+ // Detect Linux distribution if on Linux
171
+ if (os.platform() === 'linux') {
172
+ this.linuxDistro = detectLinuxDistro();
173
+ }
159
174
  }
160
175
 
161
176
  /**
@@ -164,7 +179,7 @@ class ValdiDoctor {
164
179
  * **App Development Mode (default):**
165
180
  * - Essential tools for building Valdi applications
166
181
  * - Node.js, Bazel (with version validation)
167
- * - Basic Android SDK and Java setup (Java 17+ recommended)
182
+ * - Basic Android SDK and Java setup (Java 17+ required)
168
183
  * - Core development tools (git, npm, watchman, ios-webkit-debug-proxy)
169
184
  *
170
185
  * **Project Mode (--project flag):**
@@ -221,9 +236,18 @@ class ValdiDoctor {
221
236
  // Core development dependencies
222
237
  await this.checkCoreDependencies();
223
238
 
239
+ // Git LFS initialization check
240
+ await this.checkGitLfsInitialization();
241
+
242
+ // Shell autocomplete configuration
243
+ this.checkShellAutoComplete();
244
+
245
+ // VSCode/Cursor extensions check
246
+ await this.checkEditorExtensions();
247
+
224
248
  // Framework-specific checks (only if requested)
225
249
  if (this.frameworkMode) {
226
- await this.checkFrameworkDependencies();
250
+ this.checkFrameworkDependencies();
227
251
  this.checkAdvancedAndroidSDK();
228
252
  this.checkEnvironmentVariables();
229
253
  }
@@ -598,36 +622,86 @@ class ValdiDoctor {
598
622
 
599
623
  // Check Xcode (macOS only, essential for iOS app development)
600
624
  if (os.platform() === 'darwin') {
601
- if (checkCommandExists('xcode-select')) {
602
- try {
603
- const { stdout } = await runCliCommand('xcode-select -p');
604
- this.addResult({
605
- name: 'Xcode',
606
- status: 'pass',
607
- message: `Xcode found at ${stdout.trim()}`,
608
- category: 'iOS development',
609
- });
610
- } catch {
611
- this.addResult({
612
- name: 'Xcode',
613
- status: 'warn',
614
- message: 'Xcode not properly configured',
615
- fixable: true,
616
- fixCommand: 'xcode-select --install',
617
- category: 'iOS development',
618
- });
619
- }
625
+ await this.checkXcodeInstallation();
626
+ }
627
+ }
628
+
629
+ /**
630
+ * Validates comprehensive Xcode installation and configuration.
631
+ *
632
+ * Performs thorough checks matching dev_setup requirements:
633
+ * - xcode-select command exists
634
+ * - xcode-select path is configured and valid
635
+ * - /Applications/Xcode.app exists
636
+ *
637
+ * @returns Promise that resolves when Xcode checks are complete
638
+ * @private
639
+ */
640
+ private async checkXcodeInstallation(): Promise<void> {
641
+ // Check if xcode-select command exists
642
+ if (!checkCommandExists('xcode-select')) {
643
+ this.addResult({
644
+ name: 'Xcode',
645
+ status: 'fail',
646
+ message: 'Xcode command line tools not installed',
647
+ details: 'Required for iOS app development',
648
+ fixable: true,
649
+ fixCommand: 'Install Xcode from App Store (https://apps.apple.com/us/app/xcode/id497799835)',
650
+ category: 'iOS development',
651
+ });
652
+ return;
653
+ }
654
+
655
+ // Check if Xcode is properly configured
656
+ try {
657
+ const { stdout } = await runCliCommand('xcode-select -p');
658
+ const xcodePath = stdout.trim();
659
+
660
+ if (!xcodePath || !fs.existsSync(xcodePath)) {
661
+ this.addResult({
662
+ name: 'Xcode configuration',
663
+ status: 'fail',
664
+ message: 'Xcode command line tools path is not configured correctly',
665
+ fixable: true,
666
+ fixCommand: 'Run: sudo xcode-select -s /Applications/Xcode.app (or your Xcode path)',
667
+ category: 'iOS development',
668
+ });
669
+ return;
670
+ }
671
+
672
+ // Extract Xcode.app path from the Developer path
673
+ // xcode-select -p typically returns: /Applications/Xcode.app/Contents/Developer
674
+ const xcodeAppPath = xcodePath.replace(/\/Contents\/Developer\/?$/, '');
675
+
676
+ if (fs.existsSync(xcodeAppPath) && xcodeAppPath.includes('Xcode')) {
677
+ // Xcode is installed and configured
678
+ this.addResult({
679
+ name: 'Xcode',
680
+ status: 'pass',
681
+ message: `Xcode found at ${xcodeAppPath}`,
682
+ category: 'iOS development',
683
+ });
620
684
  } else {
685
+ // Path doesn't point to an Xcode installation
621
686
  this.addResult({
622
687
  name: 'Xcode',
623
- status: 'warn',
624
- message: 'Xcode command line tools not installed',
625
- details: 'Required for iOS app development',
688
+ status: 'fail',
689
+ message: 'Xcode installation not found',
690
+ details: `xcode-select points to ${xcodePath}, but Xcode app not found at ${xcodeAppPath}`,
626
691
  fixable: true,
627
- fixCommand: 'Install Xcode from App Store and run: xcode-select --install',
692
+ fixCommand: 'Install Xcode from App Store (https://apps.apple.com/us/app/xcode/id497799835)',
628
693
  category: 'iOS development',
629
694
  });
630
695
  }
696
+ } catch {
697
+ this.addResult({
698
+ name: 'Xcode',
699
+ status: 'fail',
700
+ message: 'Xcode not properly configured',
701
+ fixable: true,
702
+ fixCommand: 'Run: sudo xcode-select -s /Applications/Xcode.app (or your Xcode path)',
703
+ category: 'iOS development',
704
+ });
631
705
  }
632
706
  }
633
707
 
@@ -679,11 +753,11 @@ class ValdiDoctor {
679
753
  } else if (majorVersion > 0) {
680
754
  this.addResult({
681
755
  name: 'Java Runtime',
682
- status: 'warn',
683
- message: `Java ${version} is outdated. Java 17+ is recommended`,
684
- details: 'dev_setup now installs Java 17 for better compatibility',
756
+ status: 'fail',
757
+ message: `Java ${version} is outdated. Java 17+ is required`,
758
+ details: 'dev_setup installs Java 17 for Android development',
685
759
  fixable: true,
686
- fixCommand: os.platform() === 'darwin' ? 'brew install openjdk@17' : 'sudo apt install openjdk-17-jdk',
760
+ fixCommand: this.getJavaInstallCommand(),
687
761
  category: 'Java installation',
688
762
  });
689
763
  } else {
@@ -711,7 +785,7 @@ class ValdiDoctor {
711
785
  message: 'Java not found in PATH',
712
786
  details: 'dev_setup installs Java JDK for Android development',
713
787
  fixable: true,
714
- fixCommand: os.platform() === 'darwin' ? 'brew install openjdk@17' : 'sudo apt install openjdk-17-jdk',
788
+ fixCommand: this.getJavaInstallCommand(),
715
789
  category: 'Java installation',
716
790
  });
717
791
  }
@@ -740,13 +814,23 @@ class ValdiDoctor {
740
814
  // Check Java tools in PATH
741
815
  const pathEnv = process.env['PATH'] || '';
742
816
  if (os.platform() === 'darwin') {
743
- if (pathEnv.includes('/opt/homebrew/opt/openjdk@17/bin') || pathEnv.includes('/opt/homebrew/opt/openjdk@11/bin')) {
817
+ if (pathEnv.includes('/opt/homebrew/opt/openjdk@17/bin')) {
744
818
  this.addResult({
745
819
  name: 'Java PATH',
746
820
  status: 'pass',
747
821
  message: 'Java tools in PATH',
748
822
  category: 'Java installation',
749
823
  });
824
+ } else if (pathEnv.includes('/opt/homebrew/opt/openjdk@11/bin')) {
825
+ this.addResult({
826
+ name: 'Java PATH',
827
+ status: 'fail',
828
+ message: 'Java 11 in PATH, but Java 17 is required',
829
+ details: 'dev_setup installs Java 17 for Android development',
830
+ fixable: true,
831
+ fixCommand: 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"',
832
+ category: 'Java installation',
833
+ });
750
834
  } else {
751
835
  this.addResult({
752
836
  name: 'Java PATH',
@@ -776,8 +860,8 @@ class ValdiDoctor {
776
860
  this.addResult({
777
861
  name: 'Java JDK symlink',
778
862
  status: 'warn',
779
- message: 'OpenJDK 11 symlink found, but Java 17+ is recommended',
780
- details: 'dev_setup now installs Java 17 for better compatibility',
863
+ message: 'OpenJDK 11 symlink found, but Java 17 is required',
864
+ details: 'dev_setup installs Java 17',
781
865
  fixable: true,
782
866
  fixCommand: 'sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk',
783
867
  category: 'Java installation',
@@ -914,22 +998,258 @@ class ValdiDoctor {
914
998
  }
915
999
  }
916
1000
 
1001
+ /**
1002
+ * Validates Git LFS initialization status.
1003
+ *
1004
+ * Checks if git-lfs is installed and properly initialized.
1005
+ * dev_setup runs `git lfs install` to configure Git LFS hooks.
1006
+ *
1007
+ * @returns Promise that resolves when Git LFS check is complete
1008
+ * @private
1009
+ */
1010
+ private async checkGitLfsInitialization(): Promise<void> {
1011
+ // First check if git-lfs command exists
1012
+ if (!checkCommandExists('git-lfs')) {
1013
+ const fixCommand = this.getFixCommandForDependency('git-lfs');
1014
+ this.addResult({
1015
+ name: 'Git LFS',
1016
+ status: 'warn',
1017
+ message: 'git-lfs not installed',
1018
+ details: 'Required for working with large files in the repository',
1019
+ fixable: true,
1020
+ fixCommand,
1021
+ category: 'Development tools',
1022
+ });
1023
+ return;
1024
+ }
1025
+
1026
+ // Check if git lfs is initialized by checking the config
1027
+ try {
1028
+ const { stdout, returnCode } = await runCliCommand('git config --global --get filter.lfs.process');
1029
+
1030
+ if (returnCode === 0 && stdout.trim()) {
1031
+ this.addResult({
1032
+ name: 'Git LFS initialization',
1033
+ status: 'pass',
1034
+ message: 'git-lfs is initialized',
1035
+ category: 'Development tools',
1036
+ });
1037
+ } else {
1038
+ this.addResult({
1039
+ name: 'Git LFS initialization',
1040
+ status: 'warn',
1041
+ message: 'git-lfs is installed but not initialized',
1042
+ details: 'Run git lfs install to configure Git LFS hooks',
1043
+ fixable: true,
1044
+ fixCommand: 'git lfs install',
1045
+ category: 'Development tools',
1046
+ });
1047
+
1048
+ if (this.autoFix) {
1049
+ await this.attemptAutoFix('git-lfs', 'git lfs install');
1050
+ }
1051
+ }
1052
+ } catch {
1053
+ this.addResult({
1054
+ name: 'Git LFS initialization',
1055
+ status: 'warn',
1056
+ message: 'git-lfs is installed but not initialized',
1057
+ details: 'Run git lfs install to configure Git LFS hooks',
1058
+ fixable: true,
1059
+ fixCommand: 'git lfs install',
1060
+ category: 'Development tools',
1061
+ });
1062
+
1063
+ if (this.autoFix) {
1064
+ await this.attemptAutoFix('git-lfs', 'git lfs install');
1065
+ }
1066
+ }
1067
+ }
1068
+
1069
+ /**
1070
+ * Validates shell autocomplete configuration.
1071
+ *
1072
+ * Checks if shell autocomplete (compinit/bashcompinit) is configured.
1073
+ * dev_setup adds these to shell RC files for better CLI experience.
1074
+ *
1075
+ * @private
1076
+ */
1077
+ private checkShellAutoComplete(): void {
1078
+ const homeDir = process.env['HOME'] ?? '';
1079
+ const shell = process.env['SHELL'] ?? '';
1080
+
1081
+ let rcFile: string | undefined;
1082
+ let requiredLines: string[] = [];
1083
+
1084
+ // Determine shell and required configuration
1085
+ if (shell.endsWith('/zsh')) {
1086
+ rcFile = path.join(homeDir, '.zshrc');
1087
+ requiredLines = ['autoload -U compinit && compinit', 'autoload -U bashcompinit && bashcompinit'];
1088
+ } else if (shell.endsWith('/bash')) {
1089
+ rcFile = path.join(homeDir, '.bashrc');
1090
+ // Bash typically auto-loads completion, so we're more lenient
1091
+ requiredLines = [];
1092
+ } else {
1093
+ // Unknown shell, skip check
1094
+ return;
1095
+ }
1096
+
1097
+ if (!rcFile || !fs.existsSync(rcFile)) {
1098
+ this.addResult({
1099
+ name: 'Shell autocomplete',
1100
+ status: 'warn',
1101
+ message: `Shell configuration file not found (${rcFile || 'unknown'})`,
1102
+ details: 'Shell autocomplete improves CLI experience',
1103
+ category: 'Development tools',
1104
+ });
1105
+ return;
1106
+ }
1107
+
1108
+ // For bash, we just report success since it typically handles completion automatically
1109
+ if (requiredLines.length === 0) {
1110
+ this.addResult({
1111
+ name: 'Shell autocomplete',
1112
+ status: 'pass',
1113
+ message: 'Shell autocomplete configured (bash)',
1114
+ category: 'Development tools',
1115
+ });
1116
+ return;
1117
+ }
1118
+
1119
+ // Read RC file and check for required lines
1120
+ try {
1121
+ const rcContent = fs.readFileSync(rcFile, 'utf8');
1122
+ const rcLines = rcContent.split('\n');
1123
+
1124
+ const missingLines: string[] = [];
1125
+ for (const required of requiredLines) {
1126
+ if (!rcLines.includes(required)) {
1127
+ missingLines.push(required);
1128
+ }
1129
+ }
1130
+
1131
+ if (missingLines.length === 0) {
1132
+ this.addResult({
1133
+ name: 'Shell autocomplete',
1134
+ status: 'pass',
1135
+ message: 'Shell autocomplete configured',
1136
+ category: 'Development tools',
1137
+ });
1138
+ } else {
1139
+ this.addResult({
1140
+ name: 'Shell autocomplete',
1141
+ status: 'warn',
1142
+ message: 'Shell autocomplete not fully configured',
1143
+ details: `Missing in ${rcFile}: ${missingLines.join(', ')}`,
1144
+ fixable: true,
1145
+ fixCommand: `Add to ${rcFile}: ${missingLines.join(' && ')}`,
1146
+ category: 'Development tools',
1147
+ });
1148
+ }
1149
+ } catch {
1150
+ this.addResult({
1151
+ name: 'Shell autocomplete',
1152
+ status: 'warn',
1153
+ message: 'Could not verify shell autocomplete configuration',
1154
+ category: 'Development tools',
1155
+ });
1156
+ }
1157
+ }
1158
+
1159
+ /**
1160
+ * Validates VSCode/Cursor extensions installation.
1161
+ *
1162
+ * Checks if Valdi extensions are installed in VSCode or Cursor:
1163
+ * - valdi-vivaldi: Device logs and language support
1164
+ * - valdi-debug: JavaScript debugger
1165
+ *
1166
+ * @returns Promise that resolves when extension checks are complete
1167
+ * @private
1168
+ */
1169
+ private async checkEditorExtensions(): Promise<void> {
1170
+ const hasCode = checkCommandExists('code');
1171
+ const hasCursor = checkCommandExists('cursor');
1172
+
1173
+ if (!hasCode && !hasCursor) {
1174
+ // No editor installed, skip check
1175
+ return;
1176
+ }
1177
+
1178
+ let extensionsInstalled = false;
1179
+
1180
+ // Check VSCode extensions
1181
+ if (hasCode) {
1182
+ try {
1183
+ const { stdout } = await runCliCommand('code --list-extensions');
1184
+ const installedExtensions = stdout.toLowerCase();
1185
+
1186
+ const hasVivaldi = installedExtensions.includes('valdi-vivaldi');
1187
+ const hasDebug = installedExtensions.includes('valdi-debug');
1188
+
1189
+ if (hasVivaldi && hasDebug) {
1190
+ extensionsInstalled = true;
1191
+ this.addResult({
1192
+ name: 'VSCode Extensions',
1193
+ status: 'pass',
1194
+ message: 'Valdi extensions installed in VSCode',
1195
+ category: 'Development tools',
1196
+ });
1197
+ }
1198
+ } catch {
1199
+ // Could not check VSCode extensions
1200
+ }
1201
+ }
1202
+
1203
+ // Check Cursor extensions
1204
+ if (hasCursor) {
1205
+ try {
1206
+ const { stdout } = await runCliCommand('cursor --list-extensions');
1207
+ const installedExtensions = stdout.toLowerCase();
1208
+
1209
+ const hasVivaldi = installedExtensions.includes('valdi-vivaldi');
1210
+ const hasDebug = installedExtensions.includes('valdi-debug');
1211
+
1212
+ if (hasVivaldi && hasDebug) {
1213
+ extensionsInstalled = true;
1214
+ this.addResult({
1215
+ name: 'Cursor Extensions',
1216
+ status: 'pass',
1217
+ message: 'Valdi extensions installed in Cursor',
1218
+ category: 'Development tools',
1219
+ });
1220
+ }
1221
+ } catch {
1222
+ // Could not check Cursor extensions
1223
+ }
1224
+ }
1225
+
1226
+ // If neither editor has extensions, show info
1227
+ if (!extensionsInstalled && (hasCode || hasCursor)) {
1228
+ const editor = hasCode ? 'VSCode' : 'Cursor';
1229
+ this.addResult({
1230
+ name: `${editor} Extensions`,
1231
+ status: 'warn',
1232
+ message: 'Valdi editor extensions not installed',
1233
+ details: 'Extensions provide syntax highlighting, debugging, and device logs',
1234
+ fixable: true,
1235
+ fixCommand: 'See installation instructions: https://github.com/Snapchat/Valdi/blob/main/docs/INSTALL.md#vscodecursor-setup-optional-but-recommended',
1236
+ category: 'Development tools',
1237
+ });
1238
+ }
1239
+ }
1240
+
917
1241
  /**
918
1242
  * Validates framework development dependencies.
919
1243
  *
920
1244
  * Additional tools needed for framework development:
921
- * - git-lfs: Large file storage
922
1245
  * - temurin: Alternative JDK (macOS)
923
1246
  *
924
- * @returns Promise that resolves when framework dependency checks are complete
1247
+ * Note: git-lfs is now checked in core dependencies with initialization verification
1248
+ *
925
1249
  * @private
926
1250
  */
927
- private async checkFrameworkDependencies(): Promise<void> {
928
- const frameworkDeps = ['git-lfs'];
929
-
930
- for (const dep of frameworkDeps) {
931
- await this.checkSingleDependency(dep, 'warn'); // Framework deps are optional
932
- }
1251
+ private checkFrameworkDependencies(): void {
1252
+ // git-lfs is now checked in core with initialization verification
933
1253
 
934
1254
  // Platform-specific framework dependencies
935
1255
  if (os.platform() === 'darwin') {
@@ -1124,6 +1444,32 @@ class ValdiDoctor {
1124
1444
  });
1125
1445
  }
1126
1446
 
1447
+ // Check platform-tools in PATH
1448
+ const pathEnvAndroid = process.env['PATH'] || '';
1449
+ const androidHomeForPath = process.env['ANDROID_HOME'];
1450
+ if (androidHomeForPath) {
1451
+ const platformToolsInPath = pathEnvAndroid.includes(`${androidHomeForPath}/platform-tools`) ||
1452
+ pathEnvAndroid.includes('platform-tools');
1453
+ if (platformToolsInPath) {
1454
+ this.addResult({
1455
+ name: 'Android platform-tools PATH',
1456
+ status: 'pass',
1457
+ message: 'Android platform-tools in PATH',
1458
+ category: 'Android installation',
1459
+ });
1460
+ } else {
1461
+ this.addResult({
1462
+ name: 'Android platform-tools PATH',
1463
+ status: 'warn',
1464
+ message: 'Android platform-tools not in PATH',
1465
+ details: 'dev_setup adds platform-tools (containing adb) to PATH',
1466
+ fixable: true,
1467
+ fixCommand: 'export PATH="$ANDROID_HOME/platform-tools:$PATH"',
1468
+ category: 'Android installation',
1469
+ });
1470
+ }
1471
+ }
1472
+
1127
1473
  // JAVA_HOME is checked in Java installation section to avoid duplication
1128
1474
 
1129
1475
  // Check PATH modifications
@@ -1152,6 +1498,22 @@ class ValdiDoctor {
1152
1498
  }
1153
1499
  }
1154
1500
 
1501
+ /**
1502
+ * Gets the appropriate Java installation command for the current platform
1503
+ * @private
1504
+ */
1505
+ private getJavaInstallCommand(): string {
1506
+ if (os.platform() === 'darwin') {
1507
+ return 'brew install openjdk@17';
1508
+ } else if (os.platform() === 'linux' && this.linuxDistro) {
1509
+ const packageMappings = getCommonPackageMappings();
1510
+ const javaPackage = getPackageName(packageMappings['openjdk-17']!, this.linuxDistro);
1511
+ return buildInstallCommand([javaPackage], this.linuxDistro);
1512
+ } else {
1513
+ return 'Install Java 17 JDK for your distribution';
1514
+ }
1515
+ }
1516
+
1155
1517
  /**
1156
1518
  * Generates platform-specific fix commands for missing dependencies.
1157
1519
  *
@@ -1164,30 +1526,78 @@ class ValdiDoctor {
1164
1526
  * @private
1165
1527
  */
1166
1528
  private getFixCommandForDependency(dep: string): string {
1167
- switch (dep) {
1168
- case 'git': {
1169
- return os.platform() === 'darwin' ? 'brew install git' : 'sudo apt-get install git';
1529
+ // macOS-specific dependencies
1530
+ if (os.platform() === 'darwin') {
1531
+ switch (dep) {
1532
+ case 'git': {
1533
+ return 'brew install git';
1534
+ }
1535
+ case 'npm': {
1536
+ return 'Install Node.js from https://nodejs.org (includes npm)';
1537
+ }
1538
+ case 'watchman': {
1539
+ return 'brew install watchman';
1540
+ }
1541
+ case 'git-lfs': {
1542
+ return 'brew install git-lfs';
1543
+ }
1544
+ case 'bazelisk': {
1545
+ return 'brew install bazelisk';
1546
+ }
1547
+ case 'ios_webkit_debug_proxy': {
1548
+ return 'brew install ios-webkit-debug-proxy';
1549
+ }
1550
+ default: {
1551
+ return `brew install ${dep}`;
1552
+ }
1553
+ }
1554
+ }
1555
+
1556
+ // Linux dependencies with distribution detection
1557
+ if (os.platform() === 'linux' && this.linuxDistro) {
1558
+ const packageMappings = getCommonPackageMappings();
1559
+
1560
+ switch (dep) {
1561
+ case 'git': {
1562
+ return buildInstallCommand(['git'], this.linuxDistro);
1563
+ }
1564
+ case 'npm': {
1565
+ return buildInstallCommand([getPackageName(packageMappings['npm']!, this.linuxDistro)], this.linuxDistro);
1566
+ }
1567
+ case 'watchman': {
1568
+ const watchmanPkg = getPackageName(packageMappings['watchman']!, this.linuxDistro);
1569
+ const cmd = buildInstallCommand([watchmanPkg], this.linuxDistro);
1570
+ // Add note for RHEL-based systems
1571
+ if (this.linuxDistro.packageManager.name === 'yum' || this.linuxDistro.packageManager.name === 'dnf') {
1572
+ return `${cmd} (may require EPEL repository)`;
1573
+ }
1574
+ return cmd;
1575
+ }
1576
+ case 'git-lfs': {
1577
+ return buildInstallCommand([getPackageName(packageMappings['git-lfs']!, this.linuxDistro)], this.linuxDistro);
1578
+ }
1579
+ case 'bazelisk': {
1580
+ return 'valdi dev_setup';
1581
+ }
1582
+ case 'adb': {
1583
+ return buildInstallCommand([getPackageName(packageMappings['adb']!, this.linuxDistro)], this.linuxDistro);
1584
+ }
1585
+ default: {
1586
+ return buildInstallCommand([dep], this.linuxDistro);
1587
+ }
1170
1588
  }
1589
+ }
1590
+
1591
+ // Fallback for unknown platforms or when distro detection fails
1592
+ switch (dep) {
1171
1593
  case 'npm': {
1172
1594
  return 'Install Node.js from https://nodejs.org (includes npm)';
1173
1595
  }
1174
- case 'watchman': {
1175
- return os.platform() === 'darwin' ? 'brew install watchman' : 'sudo apt-get install watchman';
1176
- }
1177
- case 'git-lfs': {
1178
- return os.platform() === 'darwin' ? 'brew install git-lfs' : 'sudo apt-get install git-lfs';
1179
- }
1180
1596
  case 'bazelisk': {
1181
- return os.platform() === 'darwin' ? 'brew install bazelisk' : 'valdi dev_setup';
1182
- }
1183
- case 'ios_webkit_debug_proxy': {
1184
- return 'brew install ios-webkit-debug-proxy';
1185
- }
1186
- case 'adb': {
1187
- return 'sudo apt-get install adb';
1597
+ return 'valdi dev_setup';
1188
1598
  }
1189
1599
  default: {
1190
- return os.platform() === 'darwin' ? `brew install ${dep}` : `Install ${dep}`;
1600
+ return `Install ${dep} using your system's package manager`;
1191
1601
  }
1192
1602
  }
1193
1603
  }