@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
@@ -10,6 +10,7 @@ const versions_1 = require("../setup/versions");
10
10
  const BazelClient_1 = require("../utils/BazelClient");
11
11
  const cliUtils_1 = require("../utils/cliUtils");
12
12
  const errorUtils_1 = require("../utils/errorUtils");
13
+ const linuxDistro_1 = require("../utils/linuxDistro");
13
14
  const logUtils_1 = require("../utils/logUtils");
14
15
  const DISCORD_SUPPORT_URL = 'https://discord.gg/uJyNEeYX2U';
15
16
  class ValdiDoctor {
@@ -19,12 +20,16 @@ class ValdiDoctor {
19
20
  jsonOutput;
20
21
  frameworkMode;
21
22
  projectMode;
23
+ linuxDistro;
22
24
  constructor(verbose, autoFix, jsonOutput, frameworkMode, projectMode) {
23
25
  this.verbose = verbose;
24
26
  this.autoFix = autoFix;
25
27
  this.jsonOutput = jsonOutput;
26
28
  this.frameworkMode = frameworkMode;
27
29
  this.projectMode = projectMode;
30
+ if (os.platform() === 'linux') {
31
+ this.linuxDistro = (0, linuxDistro_1.detectLinuxDistro)();
32
+ }
28
33
  }
29
34
  async runDiagnostics() {
30
35
  if (!this.jsonOutput) {
@@ -45,8 +50,11 @@ class ValdiDoctor {
45
50
  await this.checkJavaInstallation();
46
51
  this.checkAndroidSDKBasics();
47
52
  await this.checkCoreDependencies();
53
+ await this.checkGitLfsInitialization();
54
+ this.checkShellAutoComplete();
55
+ await this.checkEditorExtensions();
48
56
  if (this.frameworkMode) {
49
- await this.checkFrameworkDependencies();
57
+ this.checkFrameworkDependencies();
50
58
  this.checkAdvancedAndroidSDK();
51
59
  this.checkEnvironmentVariables();
52
60
  }
@@ -294,39 +302,67 @@ class ValdiDoctor {
294
302
  });
295
303
  }
296
304
  if (os.platform() === 'darwin') {
297
- if ((0, cliUtils_1.checkCommandExists)('xcode-select')) {
298
- try {
299
- const { stdout } = await (0, cliUtils_1.runCliCommand)('xcode-select -p');
300
- this.addResult({
301
- name: 'Xcode',
302
- status: 'pass',
303
- message: `Xcode found at ${stdout.trim()}`,
304
- category: 'iOS development',
305
- });
306
- }
307
- catch {
308
- this.addResult({
309
- name: 'Xcode',
310
- status: 'warn',
311
- message: 'Xcode not properly configured',
312
- fixable: true,
313
- fixCommand: 'xcode-select --install',
314
- category: 'iOS development',
315
- });
316
- }
305
+ await this.checkXcodeInstallation();
306
+ }
307
+ }
308
+ async checkXcodeInstallation() {
309
+ if (!(0, cliUtils_1.checkCommandExists)('xcode-select')) {
310
+ this.addResult({
311
+ name: 'Xcode',
312
+ status: 'fail',
313
+ message: 'Xcode command line tools not installed',
314
+ details: 'Required for iOS app development',
315
+ fixable: true,
316
+ fixCommand: 'Install Xcode from App Store (https://apps.apple.com/us/app/xcode/id497799835)',
317
+ category: 'iOS development',
318
+ });
319
+ return;
320
+ }
321
+ try {
322
+ const { stdout } = await (0, cliUtils_1.runCliCommand)('xcode-select -p');
323
+ const xcodePath = stdout.trim();
324
+ if (!xcodePath || !fs.existsSync(xcodePath)) {
325
+ this.addResult({
326
+ name: 'Xcode configuration',
327
+ status: 'fail',
328
+ message: 'Xcode command line tools path is not configured correctly',
329
+ fixable: true,
330
+ fixCommand: 'Run: sudo xcode-select -s /Applications/Xcode.app (or your Xcode path)',
331
+ category: 'iOS development',
332
+ });
333
+ return;
334
+ }
335
+ const xcodeAppPath = xcodePath.replace(/\/Contents\/Developer\/?$/, '');
336
+ if (fs.existsSync(xcodeAppPath) && xcodeAppPath.includes('Xcode')) {
337
+ this.addResult({
338
+ name: 'Xcode',
339
+ status: 'pass',
340
+ message: `Xcode found at ${xcodeAppPath}`,
341
+ category: 'iOS development',
342
+ });
317
343
  }
318
344
  else {
319
345
  this.addResult({
320
346
  name: 'Xcode',
321
- status: 'warn',
322
- message: 'Xcode command line tools not installed',
323
- details: 'Required for iOS app development',
347
+ status: 'fail',
348
+ message: 'Xcode installation not found',
349
+ details: `xcode-select points to ${xcodePath}, but Xcode app not found at ${xcodeAppPath}`,
324
350
  fixable: true,
325
- fixCommand: 'Install Xcode from App Store and run: xcode-select --install',
351
+ fixCommand: 'Install Xcode from App Store (https://apps.apple.com/us/app/xcode/id497799835)',
326
352
  category: 'iOS development',
327
353
  });
328
354
  }
329
355
  }
356
+ catch {
357
+ this.addResult({
358
+ name: 'Xcode',
359
+ status: 'fail',
360
+ message: 'Xcode not properly configured',
361
+ fixable: true,
362
+ fixCommand: 'Run: sudo xcode-select -s /Applications/Xcode.app (or your Xcode path)',
363
+ category: 'iOS development',
364
+ });
365
+ }
330
366
  }
331
367
  async checkJavaInstallation() {
332
368
  if ((0, cliUtils_1.checkCommandExists)('java')) {
@@ -354,11 +390,11 @@ class ValdiDoctor {
354
390
  else if (majorVersion > 0) {
355
391
  this.addResult({
356
392
  name: 'Java Runtime',
357
- status: 'warn',
358
- message: `Java ${version} is outdated. Java 17+ is recommended`,
359
- details: 'dev_setup now installs Java 17 for better compatibility',
393
+ status: 'fail',
394
+ message: `Java ${version} is outdated. Java 17+ is required`,
395
+ details: 'dev_setup installs Java 17 for Android development',
360
396
  fixable: true,
361
- fixCommand: os.platform() === 'darwin' ? 'brew install openjdk@17' : 'sudo apt install openjdk-17-jdk',
397
+ fixCommand: this.getJavaInstallCommand(),
362
398
  category: 'Java installation',
363
399
  });
364
400
  }
@@ -388,7 +424,7 @@ class ValdiDoctor {
388
424
  message: 'Java not found in PATH',
389
425
  details: 'dev_setup installs Java JDK for Android development',
390
426
  fixable: true,
391
- fixCommand: os.platform() === 'darwin' ? 'brew install openjdk@17' : 'sudo apt install openjdk-17-jdk',
427
+ fixCommand: this.getJavaInstallCommand(),
392
428
  category: 'Java installation',
393
429
  });
394
430
  }
@@ -414,7 +450,7 @@ class ValdiDoctor {
414
450
  }
415
451
  const pathEnv = process.env['PATH'] || '';
416
452
  if (os.platform() === 'darwin') {
417
- if (pathEnv.includes('/opt/homebrew/opt/openjdk@17/bin') || pathEnv.includes('/opt/homebrew/opt/openjdk@11/bin')) {
453
+ if (pathEnv.includes('/opt/homebrew/opt/openjdk@17/bin')) {
418
454
  this.addResult({
419
455
  name: 'Java PATH',
420
456
  status: 'pass',
@@ -422,6 +458,17 @@ class ValdiDoctor {
422
458
  category: 'Java installation',
423
459
  });
424
460
  }
461
+ else if (pathEnv.includes('/opt/homebrew/opt/openjdk@11/bin')) {
462
+ this.addResult({
463
+ name: 'Java PATH',
464
+ status: 'fail',
465
+ message: 'Java 11 in PATH, but Java 17 is required',
466
+ details: 'dev_setup installs Java 17 for Android development',
467
+ fixable: true,
468
+ fixCommand: 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"',
469
+ category: 'Java installation',
470
+ });
471
+ }
425
472
  else {
426
473
  this.addResult({
427
474
  name: 'Java PATH',
@@ -449,8 +496,8 @@ class ValdiDoctor {
449
496
  this.addResult({
450
497
  name: 'Java JDK symlink',
451
498
  status: 'warn',
452
- message: 'OpenJDK 11 symlink found, but Java 17+ is recommended',
453
- details: 'dev_setup now installs Java 17 for better compatibility',
499
+ message: 'OpenJDK 11 symlink found, but Java 17 is required',
500
+ details: 'dev_setup installs Java 17',
454
501
  fixable: true,
455
502
  fixCommand: 'sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk',
456
503
  category: 'Java installation',
@@ -558,11 +605,192 @@ class ValdiDoctor {
558
605
  await this.checkSingleDependency('ios_webkit_debug_proxy', 'fail');
559
606
  }
560
607
  }
561
- async checkFrameworkDependencies() {
562
- const frameworkDeps = ['git-lfs'];
563
- for (const dep of frameworkDeps) {
564
- await this.checkSingleDependency(dep, 'warn');
608
+ async checkGitLfsInitialization() {
609
+ if (!(0, cliUtils_1.checkCommandExists)('git-lfs')) {
610
+ const fixCommand = this.getFixCommandForDependency('git-lfs');
611
+ this.addResult({
612
+ name: 'Git LFS',
613
+ status: 'warn',
614
+ message: 'git-lfs not installed',
615
+ details: 'Required for working with large files in the repository',
616
+ fixable: true,
617
+ fixCommand,
618
+ category: 'Development tools',
619
+ });
620
+ return;
621
+ }
622
+ try {
623
+ const { stdout, returnCode } = await (0, cliUtils_1.runCliCommand)('git config --global --get filter.lfs.process');
624
+ if (returnCode === 0 && stdout.trim()) {
625
+ this.addResult({
626
+ name: 'Git LFS initialization',
627
+ status: 'pass',
628
+ message: 'git-lfs is initialized',
629
+ category: 'Development tools',
630
+ });
631
+ }
632
+ else {
633
+ this.addResult({
634
+ name: 'Git LFS initialization',
635
+ status: 'warn',
636
+ message: 'git-lfs is installed but not initialized',
637
+ details: 'Run git lfs install to configure Git LFS hooks',
638
+ fixable: true,
639
+ fixCommand: 'git lfs install',
640
+ category: 'Development tools',
641
+ });
642
+ if (this.autoFix) {
643
+ await this.attemptAutoFix('git-lfs', 'git lfs install');
644
+ }
645
+ }
646
+ }
647
+ catch {
648
+ this.addResult({
649
+ name: 'Git LFS initialization',
650
+ status: 'warn',
651
+ message: 'git-lfs is installed but not initialized',
652
+ details: 'Run git lfs install to configure Git LFS hooks',
653
+ fixable: true,
654
+ fixCommand: 'git lfs install',
655
+ category: 'Development tools',
656
+ });
657
+ if (this.autoFix) {
658
+ await this.attemptAutoFix('git-lfs', 'git lfs install');
659
+ }
660
+ }
661
+ }
662
+ checkShellAutoComplete() {
663
+ const homeDir = process.env['HOME'] ?? '';
664
+ const shell = process.env['SHELL'] ?? '';
665
+ let rcFile;
666
+ let requiredLines = [];
667
+ if (shell.endsWith('/zsh')) {
668
+ rcFile = path_1.default.join(homeDir, '.zshrc');
669
+ requiredLines = ['autoload -U compinit && compinit', 'autoload -U bashcompinit && bashcompinit'];
670
+ }
671
+ else if (shell.endsWith('/bash')) {
672
+ rcFile = path_1.default.join(homeDir, '.bashrc');
673
+ requiredLines = [];
565
674
  }
675
+ else {
676
+ return;
677
+ }
678
+ if (!rcFile || !fs.existsSync(rcFile)) {
679
+ this.addResult({
680
+ name: 'Shell autocomplete',
681
+ status: 'warn',
682
+ message: `Shell configuration file not found (${rcFile || 'unknown'})`,
683
+ details: 'Shell autocomplete improves CLI experience',
684
+ category: 'Development tools',
685
+ });
686
+ return;
687
+ }
688
+ if (requiredLines.length === 0) {
689
+ this.addResult({
690
+ name: 'Shell autocomplete',
691
+ status: 'pass',
692
+ message: 'Shell autocomplete configured (bash)',
693
+ category: 'Development tools',
694
+ });
695
+ return;
696
+ }
697
+ try {
698
+ const rcContent = fs.readFileSync(rcFile, 'utf8');
699
+ const rcLines = rcContent.split('\n');
700
+ const missingLines = [];
701
+ for (const required of requiredLines) {
702
+ if (!rcLines.includes(required)) {
703
+ missingLines.push(required);
704
+ }
705
+ }
706
+ if (missingLines.length === 0) {
707
+ this.addResult({
708
+ name: 'Shell autocomplete',
709
+ status: 'pass',
710
+ message: 'Shell autocomplete configured',
711
+ category: 'Development tools',
712
+ });
713
+ }
714
+ else {
715
+ this.addResult({
716
+ name: 'Shell autocomplete',
717
+ status: 'warn',
718
+ message: 'Shell autocomplete not fully configured',
719
+ details: `Missing in ${rcFile}: ${missingLines.join(', ')}`,
720
+ fixable: true,
721
+ fixCommand: `Add to ${rcFile}: ${missingLines.join(' && ')}`,
722
+ category: 'Development tools',
723
+ });
724
+ }
725
+ }
726
+ catch {
727
+ this.addResult({
728
+ name: 'Shell autocomplete',
729
+ status: 'warn',
730
+ message: 'Could not verify shell autocomplete configuration',
731
+ category: 'Development tools',
732
+ });
733
+ }
734
+ }
735
+ async checkEditorExtensions() {
736
+ const hasCode = (0, cliUtils_1.checkCommandExists)('code');
737
+ const hasCursor = (0, cliUtils_1.checkCommandExists)('cursor');
738
+ if (!hasCode && !hasCursor) {
739
+ return;
740
+ }
741
+ let extensionsInstalled = false;
742
+ if (hasCode) {
743
+ try {
744
+ const { stdout } = await (0, cliUtils_1.runCliCommand)('code --list-extensions');
745
+ const installedExtensions = stdout.toLowerCase();
746
+ const hasVivaldi = installedExtensions.includes('valdi-vivaldi');
747
+ const hasDebug = installedExtensions.includes('valdi-debug');
748
+ if (hasVivaldi && hasDebug) {
749
+ extensionsInstalled = true;
750
+ this.addResult({
751
+ name: 'VSCode Extensions',
752
+ status: 'pass',
753
+ message: 'Valdi extensions installed in VSCode',
754
+ category: 'Development tools',
755
+ });
756
+ }
757
+ }
758
+ catch {
759
+ }
760
+ }
761
+ if (hasCursor) {
762
+ try {
763
+ const { stdout } = await (0, cliUtils_1.runCliCommand)('cursor --list-extensions');
764
+ const installedExtensions = stdout.toLowerCase();
765
+ const hasVivaldi = installedExtensions.includes('valdi-vivaldi');
766
+ const hasDebug = installedExtensions.includes('valdi-debug');
767
+ if (hasVivaldi && hasDebug) {
768
+ extensionsInstalled = true;
769
+ this.addResult({
770
+ name: 'Cursor Extensions',
771
+ status: 'pass',
772
+ message: 'Valdi extensions installed in Cursor',
773
+ category: 'Development tools',
774
+ });
775
+ }
776
+ }
777
+ catch {
778
+ }
779
+ }
780
+ if (!extensionsInstalled && (hasCode || hasCursor)) {
781
+ const editor = hasCode ? 'VSCode' : 'Cursor';
782
+ this.addResult({
783
+ name: `${editor} Extensions`,
784
+ status: 'warn',
785
+ message: 'Valdi editor extensions not installed',
786
+ details: 'Extensions provide syntax highlighting, debugging, and device logs',
787
+ fixable: true,
788
+ fixCommand: 'See installation instructions: https://github.com/Snapchat/Valdi/blob/main/docs/INSTALL.md#vscodecursor-setup-optional-but-recommended',
789
+ category: 'Development tools',
790
+ });
791
+ }
792
+ }
793
+ checkFrameworkDependencies() {
566
794
  if (os.platform() === 'darwin') {
567
795
  const temurinPath = '/opt/homebrew/opt/temurin';
568
796
  if (fs.existsSync(temurinPath)) {
@@ -719,6 +947,31 @@ class ValdiDoctor {
719
947
  category: 'Android installation',
720
948
  });
721
949
  }
950
+ const pathEnvAndroid = process.env['PATH'] || '';
951
+ const androidHomeForPath = process.env['ANDROID_HOME'];
952
+ if (androidHomeForPath) {
953
+ const platformToolsInPath = pathEnvAndroid.includes(`${androidHomeForPath}/platform-tools`) ||
954
+ pathEnvAndroid.includes('platform-tools');
955
+ if (platformToolsInPath) {
956
+ this.addResult({
957
+ name: 'Android platform-tools PATH',
958
+ status: 'pass',
959
+ message: 'Android platform-tools in PATH',
960
+ category: 'Android installation',
961
+ });
962
+ }
963
+ else {
964
+ this.addResult({
965
+ name: 'Android platform-tools PATH',
966
+ status: 'warn',
967
+ message: 'Android platform-tools not in PATH',
968
+ details: 'dev_setup adds platform-tools (containing adb) to PATH',
969
+ fixable: true,
970
+ fixCommand: 'export PATH="$ANDROID_HOME/platform-tools:$PATH"',
971
+ category: 'Android installation',
972
+ });
973
+ }
974
+ }
722
975
  const pathEnv = process.env['PATH'] || '';
723
976
  if (os.platform() === 'linux') {
724
977
  if (pathEnv.includes('/.valdi/bin')) {
@@ -742,31 +995,85 @@ class ValdiDoctor {
742
995
  }
743
996
  }
744
997
  }
998
+ getJavaInstallCommand() {
999
+ if (os.platform() === 'darwin') {
1000
+ return 'brew install openjdk@17';
1001
+ }
1002
+ else if (os.platform() === 'linux' && this.linuxDistro) {
1003
+ const packageMappings = (0, linuxDistro_1.getCommonPackageMappings)();
1004
+ const javaPackage = (0, linuxDistro_1.getPackageName)(packageMappings['openjdk-17'], this.linuxDistro);
1005
+ return (0, linuxDistro_1.buildInstallCommand)([javaPackage], this.linuxDistro);
1006
+ }
1007
+ else {
1008
+ return 'Install Java 17 JDK for your distribution';
1009
+ }
1010
+ }
745
1011
  getFixCommandForDependency(dep) {
746
- switch (dep) {
747
- case 'git': {
748
- return os.platform() === 'darwin' ? 'brew install git' : 'sudo apt-get install git';
1012
+ if (os.platform() === 'darwin') {
1013
+ switch (dep) {
1014
+ case 'git': {
1015
+ return 'brew install git';
1016
+ }
1017
+ case 'npm': {
1018
+ return 'Install Node.js from https://nodejs.org (includes npm)';
1019
+ }
1020
+ case 'watchman': {
1021
+ return 'brew install watchman';
1022
+ }
1023
+ case 'git-lfs': {
1024
+ return 'brew install git-lfs';
1025
+ }
1026
+ case 'bazelisk': {
1027
+ return 'brew install bazelisk';
1028
+ }
1029
+ case 'ios_webkit_debug_proxy': {
1030
+ return 'brew install ios-webkit-debug-proxy';
1031
+ }
1032
+ default: {
1033
+ return `brew install ${dep}`;
1034
+ }
1035
+ }
1036
+ }
1037
+ if (os.platform() === 'linux' && this.linuxDistro) {
1038
+ const packageMappings = (0, linuxDistro_1.getCommonPackageMappings)();
1039
+ switch (dep) {
1040
+ case 'git': {
1041
+ return (0, linuxDistro_1.buildInstallCommand)(['git'], this.linuxDistro);
1042
+ }
1043
+ case 'npm': {
1044
+ return (0, linuxDistro_1.buildInstallCommand)([(0, linuxDistro_1.getPackageName)(packageMappings['npm'], this.linuxDistro)], this.linuxDistro);
1045
+ }
1046
+ case 'watchman': {
1047
+ const watchmanPkg = (0, linuxDistro_1.getPackageName)(packageMappings['watchman'], this.linuxDistro);
1048
+ const cmd = (0, linuxDistro_1.buildInstallCommand)([watchmanPkg], this.linuxDistro);
1049
+ if (this.linuxDistro.packageManager.name === 'yum' || this.linuxDistro.packageManager.name === 'dnf') {
1050
+ return `${cmd} (may require EPEL repository)`;
1051
+ }
1052
+ return cmd;
1053
+ }
1054
+ case 'git-lfs': {
1055
+ return (0, linuxDistro_1.buildInstallCommand)([(0, linuxDistro_1.getPackageName)(packageMappings['git-lfs'], this.linuxDistro)], this.linuxDistro);
1056
+ }
1057
+ case 'bazelisk': {
1058
+ return 'valdi dev_setup';
1059
+ }
1060
+ case 'adb': {
1061
+ return (0, linuxDistro_1.buildInstallCommand)([(0, linuxDistro_1.getPackageName)(packageMappings['adb'], this.linuxDistro)], this.linuxDistro);
1062
+ }
1063
+ default: {
1064
+ return (0, linuxDistro_1.buildInstallCommand)([dep], this.linuxDistro);
1065
+ }
749
1066
  }
1067
+ }
1068
+ switch (dep) {
750
1069
  case 'npm': {
751
1070
  return 'Install Node.js from https://nodejs.org (includes npm)';
752
1071
  }
753
- case 'watchman': {
754
- return os.platform() === 'darwin' ? 'brew install watchman' : 'sudo apt-get install watchman';
755
- }
756
- case 'git-lfs': {
757
- return os.platform() === 'darwin' ? 'brew install git-lfs' : 'sudo apt-get install git-lfs';
758
- }
759
1072
  case 'bazelisk': {
760
- return os.platform() === 'darwin' ? 'brew install bazelisk' : 'valdi dev_setup';
761
- }
762
- case 'ios_webkit_debug_proxy': {
763
- return 'brew install ios-webkit-debug-proxy';
764
- }
765
- case 'adb': {
766
- return 'sudo apt-get install adb';
1073
+ return 'valdi dev_setup';
767
1074
  }
768
1075
  default: {
769
- return os.platform() === 'darwin' ? `brew install ${dep}` : `Install ${dep}`;
1076
+ return `Install ${dep} using your system's package manager`;
770
1077
  }
771
1078
  }
772
1079
  }
@@ -119,24 +119,20 @@ async function getModuleName(argv) {
119
119
  name: 'moduleName',
120
120
  message: 'Please provide a name for this module:',
121
121
  validate: (input) => {
122
- const isEmpty = input === '';
123
- if (isEmpty) {
124
- throw new errors_1.CliError('Module name cannot be empty.');
122
+ const validationError = (0, stringUtils_1.validateProjectName)(input);
123
+ if (validationError) {
124
+ return validationError;
125
125
  }
126
- const snakeCaseName = (0, stringUtils_1.toSnakeCase)(input);
127
- const isSnakeCase = snakeCaseName === input;
128
- if (!isSnakeCase) {
129
- throw new errors_1.CliError(`Valid names may contain only A-Z, a-z, 0-9, '-', '_', '.', and must start with a letter (ie: '${snakeCaseName}').`);
130
- }
131
- const destPath = path_1.default.join(process.cwd(), input);
126
+ const sanitized = (0, stringUtils_1.sanitizeProjectName)(input);
127
+ const destPath = path_1.default.join(process.cwd(), sanitized);
132
128
  if ((0, fileUtils_1.fileExists)(destPath)) {
133
- throw new errors_1.CliError(`Path ${destPath} already exists. Choose a different name or delete the folder and try again.`);
129
+ return `Path ${destPath} already exists. Choose a different name or delete the folder and try again.`;
134
130
  }
135
131
  return true;
136
132
  },
137
133
  },
138
134
  ], {});
139
- return result.moduleName ?? '';
135
+ return (0, stringUtils_1.sanitizeProjectName)(result.moduleName ?? '');
140
136
  });
141
137
  }
142
138
  async function finalConfirmation(destPath, argv) {
@@ -164,7 +160,14 @@ async function valdiNewModule(argv) {
164
160
  const skipChecks = argv.getArgument('skipChecks');
165
161
  const checks = skipChecks ? {} : await promptChecks();
166
162
  const valdiModulePath = checks.valdiModulePath ?? path_1.default.join(await getBazelWorkspaceRoot(), 'modules');
167
- const moduleName = await getModuleName(argv);
163
+ let moduleName = await getModuleName(argv);
164
+ if (argv.getArgument('moduleName')) {
165
+ const validationError = (0, stringUtils_1.validateProjectName)(moduleName);
166
+ if (validationError) {
167
+ throw new errors_1.CliError(validationError);
168
+ }
169
+ moduleName = (0, stringUtils_1.sanitizeProjectName)(moduleName);
170
+ }
168
171
  const destPath = path_1.default.join(valdiModulePath, moduleName);
169
172
  const didConfirm = skipChecks || (await finalConfirmation(destPath, argv));
170
173
  if (!didConfirm) {
@@ -41,6 +41,9 @@ var TEMPLATE_BASE_PATHS;
41
41
  TEMPLATE_BASE_PATHS["README"] = "README.md.template";
42
42
  TEMPLATE_BASE_PATHS["WATCHMAN_CONFIG"] = ".watchmanconfig.template";
43
43
  TEMPLATE_BASE_PATHS["GIT_IGNORE"] = ".gitignore.template";
44
+ TEMPLATE_BASE_PATHS["EDITOR_CONFIG"] = ".editorconfig.template";
45
+ TEMPLATE_BASE_PATHS["CURSOR_RULES"] = ".cursorrules.template";
46
+ TEMPLATE_BASE_PATHS["AGENTS"] = "AGENTS.md.template";
44
47
  })(TEMPLATE_BASE_PATHS || (exports.TEMPLATE_BASE_PATHS = TEMPLATE_BASE_PATHS = {}));
45
48
  exports.VALID_PLATFORMS = [PLATFORM.ANDROID, PLATFORM.IOS, PLATFORM.MACOS, PLATFORM.CLI];
46
49
  exports.IOS_BAZEL_APPLICATION_TAG = 'valdi_ios_application';
package/dist/index.js CHANGED
@@ -14,6 +14,11 @@ function main() {
14
14
  .demandCommand(1, 'Need at least one command to execute')
15
15
  .recommendCommands()
16
16
  .strict()
17
+ .option('debug', {
18
+ describe: 'Run with debug logging',
19
+ type: 'boolean',
20
+ default: false,
21
+ })
17
22
  .version('version', 'Show version number', package_json_1.version)
18
23
  .scriptName('valdi')
19
24
  .wrap(yargs_1.default.terminalWidth())