@snap/valdi 1.0.1 → 1.0.6

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 (39) hide show
  1. package/.bootstrap/apps/cli_application/AGENTS.md.template +76 -0
  2. package/.bootstrap/apps/ui_application/AGENTS.md.template +79 -3
  3. package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +3 -3
  4. package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +18 -19
  5. package/.bootstrap/modules/cpp_bridge_module/src/Calculator.d.ts +3 -0
  6. package/.github/README.md +164 -0
  7. package/.metadata/.cursorrules.template +53 -0
  8. package/.metadata/.editorconfig.template +37 -0
  9. package/LINUX_COMPATIBILITY.md +248 -0
  10. package/README.md +99 -15
  11. package/dist/commands/bootstrap.js +79 -19
  12. package/dist/commands/doctor.js +361 -54
  13. package/dist/commands/newModule.js +15 -12
  14. package/dist/core/constants.js +2 -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 +117 -25
  27. package/src/commands/doctor.ts +469 -59
  28. package/src/commands/newModule.ts +18 -19
  29. package/src/core/constants.ts +2 -0
  30. package/src/setup/DevSetupHelper.ts +108 -6
  31. package/src/setup/linuxSetup.ts +235 -12
  32. package/src/setup/macOSSetup.ts +122 -8
  33. package/src/utils/githubUtils.ts +98 -2
  34. package/src/utils/linuxDistro.spec.ts +219 -0
  35. package/src/utils/linuxDistro.ts +326 -0
  36. package/src/utils/stringUtils.spec.ts +77 -1
  37. package/src/utils/stringUtils.ts +88 -0
  38. package/test/ValdiSmokeTest.ts +5 -4
  39. package/test/helpers/TypeScriptClient.ts +2 -2
@@ -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,16 +1,88 @@
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
9
21
  ```
10
22
 
11
- ## General Use
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
43
+ ```
44
+
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)
12
50
 
13
- ### New Module Creations
51
+ ### Key Commands
52
+
53
+ **`valdi dev_setup`** - Automated environment setup
54
+ - Installs all required dependencies (Bazel, Node.js, Java JDK 17, Android SDK, etc.)
55
+ - Configures environment variables and PATH
56
+ - Initializes Git LFS
57
+ - Sets up shell autocomplete
58
+ - Platform-specific: macOS (Homebrew, Xcode) or Linux (apt packages)
59
+
60
+ **`valdi doctor`** - Environment diagnostics
61
+ - Validates Node.js, Bazel, Java, Android SDK installations
62
+ - Checks Git LFS initialization
63
+ - Verifies shell autocomplete configuration
64
+ - Checks VSCode/Cursor extensions (warns if missing)
65
+ - macOS: Validates Xcode installation
66
+ - Supports `--framework` mode for additional checks
67
+ - Supports `--fix` to auto-repair issues
68
+ - Supports `--json` for CI/CD integration
69
+
70
+ **`valdi bootstrap`** - Project initialization
71
+ - Creates a new Valdi project in the current directory
72
+ - Sets up BUILD.bazel, WORKSPACE, package.json, and source files
73
+ - Supports multiple application templates (Hello World, Counter, etc.)
74
+
75
+ **`valdi install <platform>`** - Build and install
76
+ - Builds and installs app to connected device/simulator
77
+ - Platforms: `ios`, `android`, `macos`
78
+
79
+ **`valdi hotreload`** - Development server
80
+ - Enables instant hot reload during development
81
+ - Watches for file changes and updates app in milliseconds
82
+
83
+ For complete command documentation, see [Command Line Reference](https://github.com/Snapchat/Valdi/blob/main/docs/docs/command-line-references.md).
84
+
85
+ ### Creating New Modules
14
86
 
15
87
  ```sh
16
88
  valdi new_module
@@ -68,17 +140,29 @@ Options:
68
140
  --ios-module-name iOS class prefix to use for generated iOS sources. [string]
69
141
  ```
70
142
 
71
- ## Development Setup
143
+ ## For Contributors
144
+
145
+ This section is for developers working on the Valdi CLI itself.
146
+
147
+ ### Prerequisites
148
+
149
+ Set your npm registry when working on this module:
150
+
151
+ ```sh
152
+ npm config set registry https://registry.npmjs.org/
153
+ ```
154
+
155
+ ### Development Setup
72
156
 
73
- # Install dependencies
157
+ Install dependencies:
74
158
 
75
159
  ```sh
76
160
  npm install
77
161
  ```
78
162
 
79
- ## Development
163
+ ### Development
80
164
 
81
- # Run the cli
165
+ Run the CLI:
82
166
 
83
167
  ```sh
84
168
  npm run main
@@ -90,13 +174,13 @@ npm run main
90
174
  npm run main bootstrap -- --confirm-bootstrap
91
175
  ```
92
176
 
93
- # Build javascript output to ./dist
177
+ Build JavaScript output to `./dist`:
94
178
 
95
179
  ```sh
96
180
  npm run build
97
181
  ```
98
182
 
99
- # Develop with hotreload
183
+ Develop with hot reload:
100
184
 
101
185
  ```sh
102
186
  npm run watch
@@ -104,19 +188,19 @@ node ./dist/index.js
104
188
  node ./dist/index.js bootstrap --confirm-bootstrap
105
189
  ```
106
190
 
107
- # Show the help menu
191
+ Show the help menu:
108
192
 
109
193
  ```sh
110
194
  node ./dist/index.js new_module --help
111
195
  ```
112
196
 
113
- # Run unit tests
197
+ Run unit tests:
114
198
 
115
199
  ```sh
116
200
  npm test
117
201
  ```
118
202
 
119
- # Install the `valdi` command
203
+ Install the `valdi` command locally:
120
204
 
121
205
  ```sh
122
206
  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.2';
33
+ const DEFAULT_VALDI_WIDGETS_RELEASE_TAG = 'beta-0.0.2';
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,32 @@ 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),
134
167
  ];
135
168
  TEMPLATE_FILES.forEach(templateFile => {
136
169
  console.log((0, logUtils_1.wrapInColor)(`Creating ${templateFile.baseName} in ${templateFile.outputPath}...`, constants_1.ANSI_COLORS.YELLOW_COLOR));
137
170
  templateFile.expandTemplate();
138
171
  });
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
172
  const replacements = {
143
173
  MODULE_NAME: projectName,
144
174
  MODULE_NAME_PASCAL_CASED: (0, stringUtils_1.toPascalCase)(projectName),
145
175
  };
176
+ const githubSourcePath = path_1.default.join(constants_1.BOOTSTRAP_DIR_PATH, '.github');
177
+ if ((0, fileUtils_1.fileExists)(githubSourcePath)) {
178
+ console.log((0, logUtils_1.wrapInColor)('Creating GitHub templates...', constants_1.ANSI_COLORS.YELLOW_COLOR));
179
+ const githubDestPath = path_1.default.join(process.cwd(), '.github');
180
+ (0, copyBootstrapFiles_1.copyBootstrapFiles)(githubSourcePath, githubDestPath, replacements);
181
+ }
182
+ const cursorSourcePath = path_1.default.join(constants_1.META_DIR_PATH, '.cursor');
183
+ if ((0, fileUtils_1.fileExists)(cursorSourcePath)) {
184
+ console.log((0, logUtils_1.wrapInColor)('Creating Cursor AI rules...', constants_1.ANSI_COLORS.YELLOW_COLOR));
185
+ const cursorDestPath = path_1.default.join(process.cwd(), '.cursor');
186
+ (0, copyBootstrapFiles_1.copyBootstrapFiles)(cursorSourcePath, cursorDestPath, replacements);
187
+ }
188
+ console.log((0, logUtils_1.wrapInColor)(`Initializing ${template.name} application...`, constants_1.ANSI_COLORS.YELLOW_COLOR));
189
+ const sourcePath = path_1.default.join(constants_1.BOOTSTRAP_DIR_PATH, 'apps', template.path);
190
+ const destPath = process.cwd();
146
191
  (0, copyBootstrapFiles_1.copyBootstrapFiles)(sourcePath, destPath, replacements);
147
192
  }
148
193
  async function valdiBootstrap(argv) {
@@ -164,14 +209,21 @@ async function valdiBootstrap(argv) {
164
209
  throw new errors_1.CliError('Bootstrap process aborted.');
165
210
  }
166
211
  const applicationType = await getApplicationType(argv);
167
- const projectName = await getProjectName(argv);
212
+ let projectName = await getProjectName(argv);
213
+ if (argv.getArgument('projectName')) {
214
+ const validationError = (0, stringUtils_1.validateProjectName)(projectName);
215
+ if (validationError) {
216
+ throw new errors_1.CliError(validationError);
217
+ }
218
+ projectName = (0, stringUtils_1.sanitizeProjectName)(projectName);
219
+ }
168
220
  if (!projectName) {
169
221
  throw new errors_1.CliError('Project name cannot be empty.');
170
222
  }
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);
223
+ const valdiReleaseTag = await resolveValdiReleaseTag(argv, VALDI_GIT_URL, DEFAULT_VALDI_RELEASE_TAG);
224
+ const valdiWidgetsReleaseTag = await resolveValdiReleaseTag(argv, VALDI_WIDGETS_GIT_URL, DEFAULT_VALDI_WIDGETS_RELEASE_TAG, 'valdiWidgetsVersion');
225
+ const valdiImport = getValdiImport(argv, valdiReleaseTag);
226
+ const valdiWidgetsImport = getValdiWidgetsImport(argv, valdiWidgetsReleaseTag);
175
227
  console.log((0, logUtils_1.wrapInColor)('Initializing config files...', constants_1.ANSI_COLORS.BLUE_COLOR));
176
228
  initializeConfigFiles(projectName, applicationType, valdiImport, valdiWidgetsImport);
177
229
  console.log((0, logUtils_1.wrapInColor)('Verifying Bazel installation...', constants_1.ANSI_COLORS.BLUE_COLOR));
@@ -209,14 +261,22 @@ const builder = (yargs) => {
209
261
  alias: 'n',
210
262
  })
211
263
  .option('valdiImport', {
212
- describe: 'Path to a local checkout of the Valdi repo. If not specified, uses the latest release from GitHub.',
264
+ describe: 'Path to a local checkout of the Valdi repo. If not specified, uses the pinned release (see valdiVersion).',
213
265
  type: 'string',
214
266
  alias: 'l',
215
267
  })
216
268
  .option('valdiWidgetsImport', {
217
- describe: 'Path to a local checkout of the Valdi_Widgets repo. If not specified, uses the latest release from GitHub.',
269
+ describe: 'Path to a local checkout of the Valdi_Widgets repo. If not specified, uses the pinned release (see valdiWidgetsVersion).',
218
270
  type: 'string',
219
271
  alias: 'w',
272
+ })
273
+ .option('valdiVersion', {
274
+ describe: `Valdi release tag to use (e.g. v1.0.0). Use "latest" to fetch the GitHub latest release. Default: ${DEFAULT_VALDI_RELEASE_TAG}`,
275
+ type: 'string',
276
+ })
277
+ .option('valdiWidgetsVersion', {
278
+ describe: `Valdi_Widgets release tag to use. Use "latest" to fetch the GitHub latest release. Default: ${DEFAULT_VALDI_WIDGETS_RELEASE_TAG}`,
279
+ type: 'string',
220
280
  })
221
281
  .option('skipProjectsync', {
222
282
  describe: 'Skip projectsync for testing purposes',