@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
@@ -0,0 +1,248 @@
1
+ # Linux Distribution Compatibility
2
+
3
+ This document describes how the Valdi CLI handles different Linux distributions.
4
+
5
+ ## Overview
6
+
7
+ The Valdi CLI (`valdi doctor` and `valdi dev_setup` commands) now supports multiple Linux distributions beyond just Debian/Ubuntu. The CLI automatically detects your distribution and uses the appropriate package manager and package names.
8
+
9
+ ## Supported Distributions
10
+
11
+ ### Tier 1 Support (Fully Tested)
12
+ - **Debian-based**: Debian, Ubuntu, Linux Mint, Pop!_OS, etc.
13
+ - Package manager: `apt`
14
+ - Tested on: Ubuntu 22.04, Debian 12
15
+
16
+ ### Tier 2 Support (Community Tested)
17
+ - **Red Hat-based**: Fedora, RHEL, CentOS, Rocky Linux, AlmaLinux
18
+ - Package manager: `dnf` or `yum`
19
+ - Notes: Some packages (like watchman) may require EPEL repository
20
+
21
+ - **Arch-based**: Arch Linux, Manjaro, EndeavourOS
22
+ - Package manager: `pacman`
23
+ - Notes: Some packages may be in AUR
24
+
25
+ - **SUSE-based**: openSUSE, SLES
26
+ - Package manager: `zypper`
27
+
28
+ ## How Distribution Detection Works
29
+
30
+ The CLI detects your distribution using the following methods (in order):
31
+
32
+ 1. **`/etc/os-release`**: Reads the standard Linux distribution information file
33
+ - Uses `ID` and `ID_LIKE` fields to determine distribution family
34
+ - Extracts distribution name and version
35
+
36
+ 2. **Package Manager Detection**: Falls back to detecting available package managers
37
+ - Checks for `apt-get`, `dnf`, `yum`, `pacman`, or `zypper`
38
+
39
+ 3. **Unknown Distributions**: If detection fails, provides manual installation instructions
40
+
41
+ ## Package Mappings
42
+
43
+ Different distributions use different package names for the same software. The CLI includes mappings for common dependencies:
44
+
45
+ | Dependency | Debian/Ubuntu | Red Hat/Fedora | Arch Linux | openSUSE |
46
+ |------------|---------------|----------------|------------|----------|
47
+ | Java 17 JDK | `openjdk-17-jdk` | `java-17-openjdk-devel` | `jdk17-openjdk` | `java-17-openjdk-devel` |
48
+ | Android Debug Bridge | `adb` | `android-tools` | `android-tools` | `android-tools` |
49
+ | Fontconfig Dev | `libfontconfig1-dev` | `fontconfig-devel` | `fontconfig` | `fontconfig-devel` |
50
+ | Zlib Dev | `zlib1g-dev` | `zlib-devel` | `zlib` | `zlib-devel` |
51
+ | Git LFS | `git-lfs` | `git-lfs` | `git-lfs` | `git-lfs` |
52
+ | Watchman | `watchman` | `watchman` | `watchman` | `watchman` |
53
+
54
+ ## Commands
55
+
56
+ ### `valdi dev_setup`
57
+
58
+ The `dev_setup` command automatically installs required dependencies for your distribution:
59
+
60
+ ```bash
61
+ valdi dev_setup
62
+ ```
63
+
64
+ **What it does:**
65
+ 1. Detects your Linux distribution
66
+ 2. Installs the following dependencies:
67
+ - Node.js/npm (if not installed)
68
+ - Java 17 JDK
69
+ - Git LFS
70
+ - Watchman (for hot reload)
71
+ - Android Debug Bridge (adb)
72
+ - Development libraries (fontconfig, zlib)
73
+ - Additional distribution-specific packages
74
+ 3. Downloads and installs Bazelisk
75
+ 4. Sets up Android SDK with command-line tools
76
+ 5. Configures environment variables in your shell RC file
77
+
78
+ **Distribution-specific behavior:**
79
+
80
+ - **Debian/Ubuntu**:
81
+ - Sets up packagecloud repository for git-lfs
82
+ - Installs `libtinfo5` for Android command-line tools compatibility
83
+
84
+ - **Red Hat/Fedora**:
85
+ - Sets up packagecloud RPM repository for git-lfs
86
+ - Installs `ncurses-compat-libs` for Android tools
87
+ - Shows warning if EPEL repository is needed for watchman
88
+
89
+ - **Arch Linux**:
90
+ - Uses standard repositories (most packages available)
91
+ - May require AUR helper for some packages
92
+
93
+ - **openSUSE**:
94
+ - Uses zypper to install packages
95
+
96
+ ### `valdi doctor`
97
+
98
+ The `doctor` command checks your development environment and provides distribution-specific fix commands:
99
+
100
+ ```bash
101
+ valdi doctor
102
+ ```
103
+
104
+ **Features:**
105
+ - Detects your distribution automatically
106
+ - Provides correct package manager commands for your distribution
107
+ - Shows distribution-specific warnings (e.g., EPEL repository for RHEL)
108
+ - Validates all required tools are installed
109
+
110
+ **Example output on Fedora:**
111
+
112
+ ```
113
+ Running Valdi environment diagnostics...
114
+ Detected distribution: Fedora Linux (dnf)
115
+
116
+ ✓ Node.js installation
117
+ ✗ Java installation
118
+ • Java not found in PATH
119
+ Fix: sudo dnf install java-17-openjdk-devel
120
+ ```
121
+
122
+ ## Troubleshooting
123
+
124
+ ### Watchman on Red Hat/Fedora
125
+
126
+ Watchman may not be available in the default repositories. Enable EPEL:
127
+
128
+ ```bash
129
+ # Fedora
130
+ sudo dnf install epel-release
131
+
132
+ # RHEL/CentOS
133
+ sudo yum install epel-release
134
+ ```
135
+
136
+ Then install watchman:
137
+
138
+ ```bash
139
+ sudo dnf install watchman
140
+ # or
141
+ sudo yum install watchman
142
+ ```
143
+
144
+ ### Packages in AUR (Arch Linux)
145
+
146
+ Some packages may only be available in the AUR. Use an AUR helper like `yay` or `paru`:
147
+
148
+ ```bash
149
+ yay -S watchman
150
+ ```
151
+
152
+ ### Unknown Distribution
153
+
154
+ If your distribution is not automatically detected, you'll see:
155
+
156
+ ```
157
+ Unable to detect Linux distribution.
158
+ Please manually install the following dependencies and re-run this command:
159
+ - git
160
+ - git-lfs
161
+ - npm (Node.js)
162
+ - openjdk-17-jdk (or equivalent Java 17 JDK)
163
+ - watchman
164
+ - adb (Android Debug Bridge)
165
+ - fontconfig development libraries
166
+ - zlib development libraries
167
+ ```
168
+
169
+ Consult your distribution's package manager documentation for the correct package names.
170
+
171
+ ### Distribution Detection Issues
172
+
173
+ If distribution detection fails or provides incorrect results:
174
+
175
+ 1. Check that `/etc/os-release` exists and is readable:
176
+ ```bash
177
+ cat /etc/os-release
178
+ ```
179
+
180
+ 2. Verify your package manager is in PATH:
181
+ ```bash
182
+ which apt-get # or dnf, yum, pacman, zypper
183
+ ```
184
+
185
+ 3. Report the issue with your distribution details:
186
+ - Distribution name and version
187
+ - Output of `cat /etc/os-release`
188
+ - Available package manager
189
+
190
+ ## Contributing
191
+
192
+ To add support for a new distribution:
193
+
194
+ 1. Add package mappings in `src/utils/linuxDistro.ts`:
195
+ ```typescript
196
+ // In getCommonPackageMappings()
197
+ 'your-package': {
198
+ debian: 'debian-package-name',
199
+ redhat: 'redhat-package-name',
200
+ arch: 'arch-package-name',
201
+ suse: 'suse-package-name',
202
+ fallback: 'generic-package-name',
203
+ }
204
+ ```
205
+
206
+ 2. Add distribution detection logic in `detectLinuxDistro()` if needed
207
+
208
+ 3. Test on the target distribution:
209
+ ```bash
210
+ valdi dev_setup
211
+ valdi doctor
212
+ ```
213
+
214
+ 4. Update this documentation with your findings
215
+
216
+ ## Technical Details
217
+
218
+ ### Files Modified
219
+ - `src/utils/linuxDistro.ts` - Distribution detection and package mapping utilities
220
+ - `src/setup/linuxSetup.ts` - Linux-specific dev_setup implementation
221
+ - `src/commands/doctor.ts` - Environment diagnostics with distribution-aware fix commands
222
+
223
+ ### Distribution Detection API
224
+
225
+ ```typescript
226
+ import { detectLinuxDistro, buildInstallCommand, getPackageName } from './utils/linuxDistro';
227
+
228
+ // Detect distribution
229
+ const distro = detectLinuxDistro();
230
+ console.log(distro.name); // e.g., "Ubuntu"
231
+ console.log(distro.type); // e.g., LinuxDistroType.DEBIAN
232
+ console.log(distro.packageManager.name); // e.g., "apt"
233
+
234
+ // Build install command
235
+ const cmd = buildInstallCommand(['git', 'npm', 'watchman'], distro);
236
+ console.log(cmd); // e.g., "sudo apt-get install git npm watchman"
237
+
238
+ // Get package name for current distribution
239
+ const packageMappings = getCommonPackageMappings();
240
+ const javaPackage = getPackageName(packageMappings['openjdk-17'], distro);
241
+ console.log(javaPackage); // e.g., "openjdk-17-jdk" on Ubuntu
242
+ ```
243
+
244
+ ## See Also
245
+
246
+ - [Valdi Installation Guide](https://github.com/Snapchat/Valdi/blob/main/docs/INSTALL.md)
247
+ - [Development Setup Guide](https://github.com/Snapchat/Valdi/blob/main/docs/DEV_SETUP.md)
248
+ - [Contributing Guidelines](https://github.com/Snapchat/Valdi/blob/main/CONTRIBUTING.md)
package/README.md CHANGED
@@ -1,22 +1,98 @@
1
1
  # Valdi CLI
2
2
 
3
- The Valdi CLI tool provides helpful commands for working with Valdi applications.
3
+ The Valdi CLI tool provides helpful commands for setting up your environment, creating projects, building applications, and managing your Valdi workflow.
4
4
 
5
- When working on this module please set your npm registry
5
+ ## For Users
6
6
 
7
- ```sh
8
- npm config set registry https://registry.npmjs.org/
7
+ The CLI is published to npm as `@snap/valdi`:
8
+
9
+ ```bash
10
+ # Install globally
11
+ npm install -g @snap/valdi
12
+
13
+ # Set up your development environment
14
+ valdi dev_setup
15
+
16
+ # Verify your setup
17
+ valdi doctor
18
+
19
+ # Get help
20
+ valdi --help
21
+ ```
22
+
23
+ ### Create Your First App
24
+
25
+ After setting up your environment, create a new Valdi project:
26
+
27
+ ```bash
28
+ # Create a new directory for your project
29
+ mkdir my_valdi_app
30
+ cd my_valdi_app
31
+
32
+ # Initialize the project
33
+ valdi bootstrap
34
+
35
+ # Build and install on iOS
36
+ valdi install ios
37
+
38
+ # Or build and install on Android
39
+ valdi install android
40
+
41
+ # Start hot reload for development
42
+ valdi hotreload
9
43
  ```
10
44
 
11
- ## General Use
45
+ Now you can edit your TypeScript files and see changes instantly on your device!
46
+
47
+ For complete documentation, see:
48
+ - [Command Line Reference](https://github.com/Snapchat/Valdi/blob/main/docs/docs/command-line-references.md)
49
+ - [Installation Guide](https://github.com/Snapchat/Valdi/blob/main/docs/INSTALL.md)
50
+ - [Troubleshooting](https://github.com/Snapchat/Valdi/blob/main/docs/TROUBLESHOOTING.md) — run `valdi doctor` to diagnose issues, or ask on [Discord](https://discord.gg/uJyNEeYX2U)
51
+
52
+ ### Key Commands
12
53
 
13
- ### New Module Creations
54
+ **`valdi dev_setup`** - Automated environment setup
55
+ - Installs all required dependencies (Bazel, Node.js, Java JDK 17, Android SDK, etc.)
56
+ - Configures environment variables and PATH
57
+ - Initializes Git LFS
58
+ - Sets up shell autocomplete
59
+ - Platform-specific: macOS (Homebrew, Xcode) or Linux (apt packages)
60
+
61
+ **`valdi doctor`** - Environment diagnostics
62
+ - Validates Node.js, Bazel, Java, Android SDK installations
63
+ - Checks Git LFS initialization
64
+ - Verifies shell autocomplete configuration
65
+ - Checks VSCode/Cursor extensions (warns if missing)
66
+ - macOS: Validates Xcode installation
67
+ - Supports `--framework` mode for additional checks
68
+ - Supports `--fix` to auto-repair issues
69
+ - Supports `--json` for CI/CD integration
70
+
71
+ **`valdi bootstrap`** - Project initialization
72
+ - Creates a new Valdi project in the current directory
73
+ - Sets up BUILD.bazel, WORKSPACE, package.json, and source files
74
+ - Supports multiple application templates (Hello World, Counter, etc.)
75
+ - Options: `-y` (skip confirmation), `-n` (project name), `-t` (application type), `-l` (local Valdi path), `-c` (clean directory first). Run `valdi bootstrap --help` for all options.
76
+
77
+ **`valdi install <platform>`** - Build and install
78
+ - Builds and installs app to connected device/simulator
79
+ - Platforms: `ios`, `android`, `macos`
80
+
81
+ **`valdi hotreload`** - Development server
82
+ - Enables instant hot reload during development
83
+ - Watches for file changes and updates app in milliseconds
84
+
85
+ **Other commands:** `valdi build <platform>` (build without installing), `valdi package <platform>` (create distributable app), `valdi export <platform>` (export library for native apps), `valdi test` (run tests), `valdi lint check` / `valdi lint format` (lint and format code), `valdi log` (stream device logs), `valdi projectsync` (sync VS Code project and native bindings), `valdi completion` (shell autocomplete setup). Use `valdi <command> --help` for options.
86
+
87
+ For complete command documentation, see [Command Line Reference](https://github.com/Snapchat/Valdi/blob/main/docs/docs/command-line-references.md).
88
+
89
+ ### Creating New Modules
14
90
 
15
91
  ```sh
16
92
  valdi new_module
17
93
 
18
- # Create module without prompts
19
- valdi new_module my_new_module --skip-checks --android-class-path='com.example.my_module' --ios-module-name='XYZMyModule'
94
+ # Create module without prompts (specify template to skip the prompt)
95
+ valdi new_module my_new_module --skip-checks --template=ui_component
20
96
 
21
97
  # Help
22
98
  $ valdi new_module --help
@@ -60,25 +136,36 @@ Positionals:
60
136
  module-name Name of the Valdi module.
61
137
 
62
138
  Options:
63
- --debug Run with debug logging [boolean] [default: false]
64
- --version Show version number [boolean]
65
- --help Show help [boolean]
66
- --skip-checks Skips confirmation prompts. [boolean]
67
- --android-class-path Android class path to use for generated Android sources. [string]
68
- --ios-module-name iOS class prefix to use for generated iOS sources. [string]
139
+ --debug Run with debug logging [boolean] [default: false]
140
+ --version Show version number [boolean]
141
+ --help Show help [boolean]
142
+ --skip-checks Skips confirmation prompts. [boolean]
143
+ --template Module template to use (skips the prompt). One of: ui_component, ios_android_bridge_module, cpp_bridge_module, ios_android_view_module [string]
144
+ ```
145
+
146
+ ## For Contributors
147
+
148
+ This section is for developers working on the Valdi CLI itself.
149
+
150
+ ### Prerequisites
151
+
152
+ Set your npm registry when working on this module:
153
+
154
+ ```sh
155
+ npm config set registry https://registry.npmjs.org/
69
156
  ```
70
157
 
71
- ## Development Setup
158
+ ### Development Setup
72
159
 
73
- # Install dependencies
160
+ Install dependencies:
74
161
 
75
162
  ```sh
76
163
  npm install
77
164
  ```
78
165
 
79
- ## Development
166
+ ### Development
80
167
 
81
- # Run the cli
168
+ Run the CLI:
82
169
 
83
170
  ```sh
84
171
  npm run main
@@ -90,13 +177,13 @@ npm run main
90
177
  npm run main bootstrap -- --confirm-bootstrap
91
178
  ```
92
179
 
93
- # Build javascript output to ./dist
180
+ Build JavaScript output to `./dist`:
94
181
 
95
182
  ```sh
96
183
  npm run build
97
184
  ```
98
185
 
99
- # Develop with hotreload
186
+ Develop with hot reload:
100
187
 
101
188
  ```sh
102
189
  npm run watch
@@ -104,19 +191,19 @@ node ./dist/index.js
104
191
  node ./dist/index.js bootstrap --confirm-bootstrap
105
192
  ```
106
193
 
107
- # Show the help menu
194
+ Show the help menu:
108
195
 
109
196
  ```sh
110
197
  node ./dist/index.js new_module --help
111
198
  ```
112
199
 
113
- # Run unit tests
200
+ Run unit tests:
114
201
 
115
202
  ```sh
116
203
  npm test
117
204
  ```
118
205
 
119
- # Install the `valdi` command
206
+ Install the `valdi` command locally:
120
207
 
121
208
  ```sh
122
209
  npm run cli:install
@@ -29,6 +29,8 @@ const ALL_APPLICATION_TEMPLATES = [
29
29
  ];
30
30
  const VALDI_GIT_URL = 'https://github.com/Snapchat/Valdi';
31
31
  const VALDI_WIDGETS_GIT_URL = 'https://github.com/Snapchat/Valdi_Widgets';
32
+ const DEFAULT_VALDI_RELEASE_TAG = 'beta-0.0.3';
33
+ const DEFAULT_VALDI_WIDGETS_RELEASE_TAG = 'beta-0.0.3';
32
34
  const DEFAULT_VALDI_IMPORT = `
33
35
  http_archive(
34
36
  name = "valdi",
@@ -81,17 +83,46 @@ async function getApplicationType(argv) {
81
83
  }
82
84
  async function getProjectName(argv) {
83
85
  return argv.getArgumentOrResolve('projectName', async () => {
84
- const result = await inquirer_1.default.prompt([
85
- {
86
- type: 'input',
87
- name: 'projectName',
88
- message: 'Please provide a name for this project:',
89
- default: defaultProjectName,
90
- },
91
- ]);
92
- return result.projectName;
86
+ let projectName = '';
87
+ let isValid = false;
88
+ while (!isValid) {
89
+ const result = await inquirer_1.default.prompt([
90
+ {
91
+ type: 'input',
92
+ name: 'projectName',
93
+ message: 'Please provide a name for this project:',
94
+ default: defaultProjectName,
95
+ },
96
+ ]);
97
+ projectName = result.projectName;
98
+ const validationError = (0, stringUtils_1.validateProjectName)(projectName);
99
+ if (validationError) {
100
+ console.log((0, logUtils_1.wrapInColor)(`\n❌ ${validationError}\n`, constants_1.ANSI_COLORS.RED_COLOR));
101
+ continue;
102
+ }
103
+ const sanitized = (0, stringUtils_1.sanitizeProjectName)(projectName);
104
+ if (sanitized !== projectName) {
105
+ console.log((0, logUtils_1.wrapInColor)(`\n⚠️ Project name will be sanitized from "${projectName}" to "${sanitized}"`, constants_1.ANSI_COLORS.YELLOW_COLOR));
106
+ const confirm = await (0, cliUtils_1.getUserConfirmation)('Do you want to continue with this name?', true);
107
+ if (!confirm) {
108
+ continue;
109
+ }
110
+ }
111
+ isValid = true;
112
+ }
113
+ return (0, stringUtils_1.sanitizeProjectName)(projectName);
93
114
  });
94
115
  }
116
+ function resolveValdiReleaseTag(argv, gitUrl, defaultTag, versionOption = 'valdiVersion') {
117
+ const override = argv.getArgument(versionOption);
118
+ if (!override) {
119
+ return Promise.resolve(defaultTag);
120
+ }
121
+ if (override === 'latest') {
122
+ return (0, githubUtils_1.getLatestReleaseTag)(gitUrl);
123
+ }
124
+ return Promise.resolve(override);
125
+ }
95
126
  function getValdiImport(argv, valdiReleaseRef) {
96
127
  const valdiImport = argv.getArgument('valdiImport');
97
128
  if (valdiImport) {
@@ -131,18 +162,33 @@ function initializeConfigFiles(projectName, template, valdiImport, valdiWidgetsI
131
162
  fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.README),
132
163
  fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.GIT_IGNORE),
133
164
  fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.WATCHMAN_CONFIG),
165
+ fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.EDITOR_CONFIG),
166
+ fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.CURSOR_RULES),
167
+ fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.AGENTS).withReplacements({ MODULE_NAME: projectName }),
134
168
  ];
135
169
  TEMPLATE_FILES.forEach(templateFile => {
136
170
  console.log((0, logUtils_1.wrapInColor)(`Creating ${templateFile.baseName} in ${templateFile.outputPath}...`, constants_1.ANSI_COLORS.YELLOW_COLOR));
137
171
  templateFile.expandTemplate();
138
172
  });
139
- console.log((0, logUtils_1.wrapInColor)(`Initializing ${template.name} application...`, constants_1.ANSI_COLORS.YELLOW_COLOR));
140
- const sourcePath = path_1.default.join(constants_1.BOOTSTRAP_DIR_PATH, 'apps', template.path);
141
- const destPath = process.cwd();
142
173
  const replacements = {
143
174
  MODULE_NAME: projectName,
144
175
  MODULE_NAME_PASCAL_CASED: (0, stringUtils_1.toPascalCase)(projectName),
145
176
  };
177
+ const githubSourcePath = path_1.default.join(constants_1.BOOTSTRAP_DIR_PATH, '.github');
178
+ if ((0, fileUtils_1.fileExists)(githubSourcePath)) {
179
+ console.log((0, logUtils_1.wrapInColor)('Creating GitHub templates...', constants_1.ANSI_COLORS.YELLOW_COLOR));
180
+ const githubDestPath = path_1.default.join(process.cwd(), '.github');
181
+ (0, copyBootstrapFiles_1.copyBootstrapFiles)(githubSourcePath, githubDestPath, replacements);
182
+ }
183
+ const cursorSourcePath = path_1.default.join(constants_1.META_DIR_PATH, '.cursor');
184
+ if ((0, fileUtils_1.fileExists)(cursorSourcePath)) {
185
+ console.log((0, logUtils_1.wrapInColor)('Creating Cursor AI rules...', constants_1.ANSI_COLORS.YELLOW_COLOR));
186
+ const cursorDestPath = path_1.default.join(process.cwd(), '.cursor');
187
+ (0, copyBootstrapFiles_1.copyBootstrapFiles)(cursorSourcePath, cursorDestPath, replacements);
188
+ }
189
+ console.log((0, logUtils_1.wrapInColor)(`Initializing ${template.name} application...`, constants_1.ANSI_COLORS.YELLOW_COLOR));
190
+ const sourcePath = path_1.default.join(constants_1.BOOTSTRAP_DIR_PATH, 'apps', template.path);
191
+ const destPath = process.cwd();
146
192
  (0, copyBootstrapFiles_1.copyBootstrapFiles)(sourcePath, destPath, replacements);
147
193
  }
148
194
  async function valdiBootstrap(argv) {
@@ -164,14 +210,21 @@ async function valdiBootstrap(argv) {
164
210
  throw new errors_1.CliError('Bootstrap process aborted.');
165
211
  }
166
212
  const applicationType = await getApplicationType(argv);
167
- const projectName = await getProjectName(argv);
213
+ let projectName = await getProjectName(argv);
214
+ if (argv.getArgument('projectName')) {
215
+ const validationError = (0, stringUtils_1.validateProjectName)(projectName);
216
+ if (validationError) {
217
+ throw new errors_1.CliError(validationError);
218
+ }
219
+ projectName = (0, stringUtils_1.sanitizeProjectName)(projectName);
220
+ }
168
221
  if (!projectName) {
169
222
  throw new errors_1.CliError('Project name cannot be empty.');
170
223
  }
171
- const valdiCommitHash = await (0, githubUtils_1.resolveLatestReleaseRef)(`${VALDI_GIT_URL}.git`);
172
- const valdiWidgetsCommitHash = await (0, githubUtils_1.resolveLatestReleaseRef)(`${VALDI_WIDGETS_GIT_URL}.git`);
173
- const valdiImport = getValdiImport(argv, valdiCommitHash);
174
- const valdiWidgetsImport = getValdiWidgetsImport(argv, valdiWidgetsCommitHash);
224
+ const valdiReleaseTag = await resolveValdiReleaseTag(argv, VALDI_GIT_URL, DEFAULT_VALDI_RELEASE_TAG);
225
+ const valdiWidgetsReleaseTag = await resolveValdiReleaseTag(argv, VALDI_WIDGETS_GIT_URL, DEFAULT_VALDI_WIDGETS_RELEASE_TAG, 'valdiWidgetsVersion');
226
+ const valdiImport = getValdiImport(argv, valdiReleaseTag);
227
+ const valdiWidgetsImport = getValdiWidgetsImport(argv, valdiWidgetsReleaseTag);
175
228
  console.log((0, logUtils_1.wrapInColor)('Initializing config files...', constants_1.ANSI_COLORS.BLUE_COLOR));
176
229
  initializeConfigFiles(projectName, applicationType, valdiImport, valdiWidgetsImport);
177
230
  console.log((0, logUtils_1.wrapInColor)('Verifying Bazel installation...', constants_1.ANSI_COLORS.BLUE_COLOR));
@@ -209,14 +262,22 @@ const builder = (yargs) => {
209
262
  alias: 'n',
210
263
  })
211
264
  .option('valdiImport', {
212
- describe: 'Path to a local checkout of the Valdi repo. If not specified, uses the latest release from GitHub.',
265
+ describe: 'Path to a local checkout of the Valdi repo. If not specified, uses the pinned release (see valdiVersion).',
213
266
  type: 'string',
214
267
  alias: 'l',
215
268
  })
216
269
  .option('valdiWidgetsImport', {
217
- describe: 'Path to a local checkout of the Valdi_Widgets repo. If not specified, uses the latest release from GitHub.',
270
+ describe: 'Path to a local checkout of the Valdi_Widgets repo. If not specified, uses the pinned release (see valdiWidgetsVersion).',
218
271
  type: 'string',
219
272
  alias: 'w',
273
+ })
274
+ .option('valdiVersion', {
275
+ describe: `Valdi release tag to use (e.g. v1.0.0). Use "latest" to fetch the GitHub latest release. Default: ${DEFAULT_VALDI_RELEASE_TAG}`,
276
+ type: 'string',
277
+ })
278
+ .option('valdiWidgetsVersion', {
279
+ describe: `Valdi_Widgets release tag to use. Use "latest" to fetch the GitHub latest release. Default: ${DEFAULT_VALDI_WIDGETS_RELEASE_TAG}`,
280
+ type: 'string',
220
281
  })
221
282
  .option('skipProjectsync', {
222
283
  describe: 'Skip projectsync for testing purposes',