@snap/valdi 1.2.0 → 1.2.1

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.
@@ -2,7 +2,6 @@
2
2
  common --registry=https://raw.githubusercontent.com/Snapchat/Valdi/{{VALDI_RELEASE_TAG}}/registry
3
3
  common --registry=https://bcr.bazel.build
4
4
 
5
- common --bes_instance_name=client
6
5
  common --enable_platform_specific_config
7
6
 
8
7
  # Disable workers for repo fetching to prevent OOM
@@ -40,7 +39,7 @@ build --incompatible_use_specific_tool_files=false
40
39
  ## For Objective-C source files
41
40
  build --per_file_copt=.*\.mm\$@-std=c++20
42
41
  build --host_per_file_copt=.*\.mm\$@-std=c++20
43
- build --ios_minimum_os=12.0
42
+ build --ios_minimum_os=15.0
44
43
 
45
44
  ## TODO: (dchapp) this is currently needed otherwise -O0 and -DDEBUG=1 get passed to compilations of .mm/.m for production flavor builds
46
45
  build --experimental_objc_fastbuild_options=""
@@ -74,7 +73,6 @@ build:macos --spawn_strategy=local
74
73
  build:linux --sandbox_writable_path=/var/tmp
75
74
 
76
75
  # Disable disk cache to save disk space
77
- # https://docs.google.com/document/d/1N8W_M83n9jhMi7pgUhXuEuxypb3dmlHBu_CG_eXipXI/edit?usp=sharing
78
76
  build --disk_cache=""
79
77
 
80
78
  # common build configuration
@@ -86,8 +84,6 @@ build --generate_json_trace_profile
86
84
  # CLI passes to its build/test flows so they converge; raw `bazel` keeps the
87
85
  # default. Changing test flags (e.g. --test_output) repopulates it once.
88
86
  build:stable_exec --notrim_test_configuration
89
- # enable grpc log
90
- build --remote_grpc_log=/tmp/snap_client_grpc.log
91
87
  build --experimental_reuse_sandbox_directories
92
88
 
93
89
  # Default JS engine
@@ -13,4 +13,11 @@ valdi skills install # installs skills for Claude Code, Cursor, or Copi
13
13
 
14
14
  Skills are bundled in the npm package and work offline. They cover component patterns, lifecycle, async handling, build rules, testing, and platform bridging.
15
15
 
16
+ ## Security: Handling Credentials
17
+
18
+ 1. **Never print credential files or secrets.** When diagnosing setup, install, or registry problems, do not `cat`, `head`, `grep`, or otherwise echo `~/.npmrc`, `~/.netrc`, `~/.gitconfig` credential sections, `~/.docker/config.json`, Bazel credential helpers, `.env` files, or environment variables that may hold tokens. Tool output ends up in transcripts and logs.
19
+ 2. **Read only the setting you need, by key.** For example `npm config get registry` (never `npm config list`, which can include auth values) or `git config --get remote.origin.url`.
20
+ 3. **If you must inspect such a file, redact first** and print key names only, e.g. `sed -E 's/(_authToken|_auth|_password|password|token)[[:space:]]*=.*/\1=<redacted>/' ~/.npmrc`.
21
+ 4. **If a secret is exposed anyway, say so plainly** so the user can rotate it.
22
+
16
23
  For documentation and support: https://github.com/Snapchat/Valdi
@@ -169,3 +169,30 @@ python.single_version_platform_override(
169
169
  platform = "aarch64-apple-darwin",
170
170
  python_version = "3.11.14",
171
171
  )
172
+
173
+ # -- Rust toolchain ------------------------------------------------------------
174
+ # rules_rust only honors rust.toolchain() from the root module, so Valdi's own
175
+ # toolchain config does not reach bootstrapped apps. Mirror it here.
176
+ # -Cstrip=none for exec-config (host tool / proc-macro) builds: rustc's
177
+ # debuginfo strip leaves a misaligned LINKEDIT string table that macOS 27 dyld
178
+ # rejects when the dylib was linked against SDK 27 (rust-lang/rust#157750,
179
+ # fixed in Rust 1.98.0).
180
+ bazel_dep(name = "rules_rust", version = "0.64.0")
181
+
182
+ rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
183
+ rust.toolchain(
184
+ edition = "2024",
185
+ extra_exec_rustc_flags = ["-Cstrip=none"],
186
+ extra_target_triples = [
187
+ "aarch64-apple-ios",
188
+ "aarch64-apple-ios-sim",
189
+ "aarch64-linux-android",
190
+ "armv7-linux-androideabi",
191
+ "x86_64-apple-ios",
192
+ "x86_64-linux-android",
193
+ ],
194
+ versions = ["1.87.0"],
195
+ )
196
+ use_repo(rust, "rust_toolchains")
197
+
198
+ register_toolchains("@rust_toolchains//:all")
@@ -1,5 +1,5 @@
1
- # valdi_demo
2
- Demo of a hello world app using Valdi open source
1
+ # {{PROJECT_NAME}}
2
+ A [Valdi](https://github.com/Snapchat/Valdi) application.
3
3
 
4
4
  ## Usage
5
5
 
@@ -5,7 +5,7 @@ Compile check for the patterns taught in `../skill.md`.
5
5
  ## Compile check
6
6
 
7
7
  ```bash
8
- cd client/src/open_source
8
+ cd <valdi-repo-root>
9
9
  bazel build //ai-skills/skills/SKILL_NAME/tests:tests
10
10
  ```
11
11
 
package/README.md CHANGED
@@ -52,17 +52,15 @@ For complete documentation, see:
52
52
  ### Key Commands
53
53
 
54
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
55
+ - Installs required dependencies: Bazelisk, Java JDK 17, Watchman and adb (Homebrew on macOS, your distro's package manager on Linux)
56
+ - Configures `PATH` and `JAVA_HOME` in your shell profile; asks for `sudo` for package installs and (macOS) the JDK symlink
58
57
  - Sets up shell autocomplete
59
- - Platform-specific: macOS (Homebrew, Xcode) or Linux (apt packages)
58
+ - The Android SDK/NDK aren't installed; Bazel downloads them during the build
59
+ - Requires Node.js 18+ and, on macOS, Xcode 26.5 or 27
60
60
 
61
61
  **`valdi doctor`** - Environment diagnostics
62
- - Validates Node.js, Bazel, Java, Android SDK installations
63
- - Checks Git LFS initialization
62
+ - Validates Node.js, Bazel, Java, Android SDK and adb installations
64
63
  - Verifies shell autocomplete configuration
65
- - Checks VSCode/Cursor extensions (warns if missing)
66
64
  - macOS: Validates Xcode installation
67
65
  - Supports `--framework` mode for additional checks
68
66
  - Supports `--fix` to auto-repair issues
@@ -70,13 +68,14 @@ For complete documentation, see:
70
68
 
71
69
  **`valdi bootstrap`** - Project initialization
72
70
  - 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.)
71
+ - Sets up `MODULE.bazel`, `.bazelrc`, `BUILD.bazel` and source files, pinned to the latest framework release (override with `--valdiVersion=<tag>`)
72
+ - Application templates: `ui_application` and `cli_application`
75
73
  - 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
74
 
77
75
  **`valdi install <platform>`** - Build and install
78
- - Builds and installs app to connected device/simulator
79
- - Platforms: `ios`, `android`, `macos`
76
+ - Builds and installs app to connected device/simulator, or serves web apps locally
77
+ - Platforms: `ios`, `android`, `macos`, `web`
78
+ - Web opens the default browser unless `--no-open` is passed
80
79
 
81
80
  **`valdi hotreload`** - Development server
82
81
  - Enables instant hot reload during development
@@ -98,7 +97,7 @@ For complete documentation, see:
98
97
  - `valdi skills update` — re-install already-installed skills from the bundled package
99
98
  - `valdi skills create` — scaffold a new skill (run from within the Valdi repo)
100
99
 
101
- **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.
100
+ **Other commands:** `valdi build <platform>` (build without installing), `valdi package <platform>` (create distributable app), `valdi export <platform>` (export a library artifact), `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.
102
101
 
103
102
  For complete command documentation, see [Command Line Reference](https://github.com/Snapchat/Valdi/blob/main/docs/docs/command-line-references.md).
104
103
 
@@ -125,7 +124,7 @@ Requirements for Valdi module names:
125
124
 
126
125
  Recommended Directory Structure:
127
126
  my_application/ # Root directory of your application
128
- ├── WORKSPACE # Bazel Workspace
127
+ ├── MODULE.bazel # Bazel module (dependencies)
129
128
  ├── BUILD.bazel # Bazel build
130
129
  └── modules/
131
130
  ├── module_a/
@@ -14,7 +14,7 @@ Compile check for the async lifecycle safety patterns taught in `skill.md`.
14
14
  ## Compile check
15
15
 
16
16
  ```bash
17
- cd client/src/open_source
17
+ cd <valdi-repo-root>
18
18
  bazel build //ai-skills/skills/valdi-async/tests:tests
19
19
  ```
20
20
 
@@ -24,7 +24,7 @@ Reference spec file demonstrating all test utility patterns from `skill.md`.
24
24
  ## Run tests
25
25
 
26
26
  ```bash
27
- cd client/src/open_source
27
+ cd <valdi-repo-root>
28
28
  bazel test //ai-skills/skills/valdi-component-tests/tests:tests
29
29
  ```
30
30
 
@@ -53,7 +53,7 @@ class MyComponent extends Component<MyViewModel> {
53
53
  }
54
54
  ```
55
55
 
56
- `viewFactory` and `*Class` attributes are mutually exclusive — use one or the other. `viewFactory` takes precedence when both are provided.
56
+ `viewFactory` and `*Class` attributes are mutually exclusive — use one or the other. Specifying both on the same `<custom-view>` is a compile error (the JSXProcessor rejects it). If a view needs a `viewFactory` on one platform and a registered class on another, branch into two sibling `<custom-view>` elements, each with a single mechanism. Prefer gating on whether a `viewFactory` is provided (`if (viewFactory) { … } else { …class… }`) over `Device.isWeb()`: the factory is often supplied by native too, so an `isWeb` branch that routes native to classes can break it. Only keep a platform class you've confirmed actually exists.
57
57
 
58
58
  ## macOS Attribute Binding
59
59
 
@@ -41,7 +41,7 @@ Save each output to the `output/` directory:
41
41
  Verify none of the outputs contain framework-specific patterns:
42
42
 
43
43
  ```bash
44
- cd client/src/open_source/ai-skills/skills/valdi-migrate/tests
44
+ cd <valdi-repo-root>/ai-skills/skills/valdi-migrate/tests
45
45
 
46
46
  python3 check_antipatterns.py output/flutter_migrated.tsx # must pass
47
47
  python3 check_antipatterns.py output/compose_migrated.tsx # must pass
@@ -57,7 +57,7 @@ python3 check_antipatterns.py compose_example.kt # expected: fail
57
57
  Verify all outputs (reference + migrations) build with the Valdi compiler:
58
58
 
59
59
  ```bash
60
- cd client/src/open_source
60
+ cd <valdi-repo-root>
61
61
  bazel build //ai-skills/skills/valdi-migrate/tests:tests
62
62
  ```
63
63
 
@@ -15,7 +15,7 @@ Compile check for the performance patterns taught in `skill.md`.
15
15
  ## Compile check
16
16
 
17
17
  ```bash
18
- cd client/src/open_source
18
+ cd <valdi-repo-root>
19
19
  bazel build //ai-skills/skills/valdi-perf/tests:tests
20
20
  ```
21
21
 
@@ -18,7 +18,7 @@ Compile check for the core TSX component patterns taught in `skill.md`.
18
18
  ## Compile check
19
19
 
20
20
  ```bash
21
- cd client/src/open_source
21
+ cd <valdi-repo-root>
22
22
  bazel build //ai-skills/skills/valdi-tsx/tests:tests
23
23
  ```
24
24
 
@@ -30,8 +30,8 @@ const ALL_APPLICATION_TEMPLATES = [
30
30
  ];
31
31
  const VALDI_GIT_URL = 'https://github.com/Snapchat/Valdi';
32
32
  const VALDI_WIDGETS_GIT_URL = 'https://github.com/Snapchat/Valdi_Widgets';
33
- const DEFAULT_VALDI_RELEASE_TAG = 'beta-0.2.0';
34
- const DEFAULT_VALDI_WIDGETS_RELEASE_TAG = 'beta-0.2.0';
33
+ const DEFAULT_VALDI_RELEASE_TAG = 'beta-0.2.1';
34
+ const DEFAULT_VALDI_WIDGETS_RELEASE_TAG = 'beta-0.2.1';
35
35
  function isAlreadyInitialized() {
36
36
  return (0, fileUtils_1.fileExists)(path_1.default.join(process.cwd(), 'MODULE.bazel')) || (0, fileUtils_1.fileExists)(path_1.default.join(process.cwd(), 'WORKSPACE'));
37
37
  }
@@ -112,7 +112,7 @@ function initializeConfigFiles(projectName, template, valdiReleaseTag, valdiWidg
112
112
  fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.BAZEL_RC).withReplacements({
113
113
  VALDI_RELEASE_TAG: valdiReleaseTag,
114
114
  }),
115
- fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.README),
115
+ fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.README).withReplacements({ PROJECT_NAME: projectName }),
116
116
  fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.GIT_IGNORE),
117
117
  fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.WATCHMAN_CONFIG),
118
118
  fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.EDITOR_CONFIG),
@@ -44,6 +44,12 @@ async function valdiBuild(argv) {
44
44
  await bazel.buildTarget(buildInfo.application, buildInfo.bazelArgs);
45
45
  break;
46
46
  }
47
+ case constants_1.PLATFORM.WEB: {
48
+ (0, errorUtils_1.logReproduceThisCommandIfNeeded)(argv);
49
+ console.log('Building web application...');
50
+ await bazel.buildTarget(buildInfo.application, buildInfo.bazelArgs);
51
+ break;
52
+ }
47
53
  }
48
54
  }
49
55
  exports.command = 'build <platform>';
@@ -66,7 +72,7 @@ exports.builder = (0, applicationUtils_1.makeArgsBuilder)((yargs) => {
66
72
  requiresArg: true,
67
73
  })
68
74
  .option('simulator', {
69
- describe: 'Whether to build for simulator or for device',
75
+ describe: 'Build for the iOS simulator (default). Pass --no-simulator to build for a device',
70
76
  type: 'boolean',
71
77
  });
72
78
  });
@@ -8,11 +8,13 @@ const constants_1 = require("../core/constants");
8
8
  const errors_1 = require("../core/errors");
9
9
  const BazelClient_1 = require("../utils/BazelClient");
10
10
  const applicationUtils_1 = require("../utils/applicationUtils");
11
+ const directorySync_1 = require("../utils/directorySync");
11
12
  const errorUtils_1 = require("../utils/errorUtils");
12
13
  const fileUtils_1 = require("../utils/fileUtils");
13
14
  const logUtils_1 = require("../utils/logUtils");
14
15
  const tempDir_1 = require("../utils/tempDir");
15
16
  const zipUtils_1 = require("../utils/zipUtils");
17
+ const OUTPUT_FORMATS = ['archive', 'directory'];
16
18
  async function decompressAndMoveXCFrameworkIntoDestination(bazelOutputFilePath, resolvedOutputPath) {
17
19
  await (0, tempDir_1.withTempDir)(async (tempDir) => {
18
20
  await (0, zipUtils_1.decompressTo)(bazelOutputFilePath, tempDir);
@@ -24,37 +26,61 @@ async function decompressAndMoveXCFrameworkIntoDestination(bazelOutputFilePath,
24
26
  await fs.promises.rename(inputDir, resolvedOutputPath);
25
27
  });
26
28
  }
29
+ function getExportOutputExtension(platform) {
30
+ return (0, applicationUtils_1.exportedLibraryExtensionForPlatform)(platform);
31
+ }
32
+ async function getTargetToExport(argv, bazel, platform) {
33
+ return await argv.getArgumentOrResolve('library', () => {
34
+ console.log('No library specified querying available targets...');
35
+ return (0, applicationUtils_1.selectBazelTarget)(bazel, (0, applicationUtils_1.getExportedLibraryTargetTagForPlatform)(platform), 'valdi_exported_library', 'Please select a library to export:');
36
+ });
37
+ }
27
38
  async function valdiExport(argv) {
28
39
  const bazel = new BazelClient_1.BazelClient();
29
40
  const platform = argv.getArgument('platform');
30
41
  const bazelArgs = (0, applicationUtils_1.resolveBazelBuildArgs)(platform, argv.getArgument('build_config'), constants_1.ALL_ARCHITECTURES, false, argv.getArgument('enable_runtime_logs'), argv.getArgument('enable_runtime_traces'), argv.getArgument('bazel_args'));
31
42
  const resolvedOutputPath = path_1.default.resolve(argv.getArgument('output_path'));
32
- const expectedExtension = (0, applicationUtils_1.exportedLibraryExtensionForPlatform)(platform);
33
- if (!resolvedOutputPath.endsWith(expectedExtension)) {
43
+ const outputFormat = argv.getArgument('output_format');
44
+ const expectedExtension = getExportOutputExtension(platform);
45
+ if (outputFormat === 'directory' && platform !== constants_1.PLATFORM.WEB) {
46
+ throw new errors_1.CliError("The 'directory' output format is only supported for web exports");
47
+ }
48
+ if (outputFormat === 'archive' && !resolvedOutputPath.endsWith(expectedExtension)) {
34
49
  throw new errors_1.CliError(`Output path for platform '${platform}' must have ${expectedExtension} file extension`);
35
50
  }
36
- (0, fileUtils_1.removeFileOrDirAtPath)(resolvedOutputPath);
51
+ if (outputFormat === 'archive') {
52
+ (0, fileUtils_1.removeFileOrDirAtPath)(resolvedOutputPath);
53
+ }
37
54
  const directoryPath = path_1.default.dirname(resolvedOutputPath);
38
55
  if (!fs.existsSync(directoryPath)) {
39
56
  fs.mkdirSync(directoryPath, { recursive: true });
40
57
  }
41
- const library = await argv.getArgumentOrResolve('library', () => {
42
- console.log('No library specified querying available targets...');
43
- return (0, applicationUtils_1.selectBazelTarget)(bazel, (0, applicationUtils_1.getExportedLibraryTargetTagForPlatform)(platform), 'valdi_exported_library', 'Please select a library to export:');
44
- });
45
- console.log('Resolving output paths...');
46
- const bazelOutputExtension = platform === constants_1.PLATFORM.IOS ? '.zip' : expectedExtension;
58
+ const targetToExport = await getTargetToExport(argv, bazel, platform);
59
+ const bazelOutputExtension = platform === constants_1.PLATFORM.IOS ? '.zip' : platform === constants_1.PLATFORM.WEB ? '' : expectedExtension;
47
60
  const bazelOutputFilePath = await argv.getArgumentOrResolve('target_output_path', () => {
48
61
  console.log('Resolving output paths...');
49
- return (0, applicationUtils_1.getOutputFilePath)(bazel, bazelOutputExtension, library, bazelArgs);
62
+ return (0, applicationUtils_1.getOutputFilePath)(bazel, bazelOutputExtension, targetToExport, bazelArgs);
50
63
  });
51
- console.log(`Building: ${(0, logUtils_1.wrapInColor)(library, constants_1.ANSI_COLORS.GREEN_COLOR)}`);
52
- await bazel.buildTarget(library, bazelArgs);
53
- console.log(`Copying built target to ${resolvedOutputPath}...`);
54
- if (platform === constants_1.PLATFORM.IOS) {
64
+ console.log(`Building: ${(0, logUtils_1.wrapInColor)(targetToExport, constants_1.ANSI_COLORS.GREEN_COLOR)}`);
65
+ await bazel.buildTarget(targetToExport, bazelArgs);
66
+ if (platform === constants_1.PLATFORM.WEB) {
67
+ if (outputFormat === 'directory') {
68
+ console.log(`Synchronizing built target to ${resolvedOutputPath}...`);
69
+ const syncResult = await (0, directorySync_1.syncDirectoryContents)(bazelOutputFilePath, resolvedOutputPath);
70
+ console.log(`Directory export: ${syncResult.added} added, ${syncResult.updated} updated, ` +
71
+ `${syncResult.removed} removed, ${syncResult.unchanged} unchanged`);
72
+ }
73
+ else {
74
+ console.log(`Copying built target to ${resolvedOutputPath}...`);
75
+ await (0, zipUtils_1.compressDirectoryContentsTo)(bazelOutputFilePath, resolvedOutputPath);
76
+ }
77
+ }
78
+ else if (platform === constants_1.PLATFORM.IOS) {
79
+ console.log(`Copying built target to ${resolvedOutputPath}...`);
55
80
  await decompressAndMoveXCFrameworkIntoDestination(bazelOutputFilePath, resolvedOutputPath);
56
81
  }
57
82
  else {
83
+ console.log(`Copying built target to ${resolvedOutputPath}...`);
58
84
  await fs.promises.copyFile(bazelOutputFilePath, resolvedOutputPath);
59
85
  }
60
86
  (0, errorUtils_1.logReproduceThisCommandIfNeeded)(argv);
@@ -65,7 +91,7 @@ exports.describe = 'Build and export a Valdi library';
65
91
  exports.builder = (0, applicationUtils_1.makeArgsBuilder)((yargs) => {
66
92
  yargs
67
93
  .option('library', {
68
- describe: 'Name of the library to build',
94
+ describe: 'Name of the library to export',
69
95
  type: 'string',
70
96
  requiresArg: true,
71
97
  })
@@ -75,9 +101,14 @@ exports.builder = (0, applicationUtils_1.makeArgsBuilder)((yargs) => {
75
101
  requiresArg: true,
76
102
  })
77
103
  .option('output_path', {
78
- describe: 'The path where to store the built application package',
104
+ describe: 'The path where to store the exported library artifact or directory',
79
105
  type: 'string',
80
106
  requiresArg: true,
107
+ })
108
+ .option('output_format', {
109
+ choices: OUTPUT_FORMATS,
110
+ default: 'archive',
111
+ describe: 'Export web output as an archive or a content-synchronized directory',
81
112
  })
82
113
  .demandOption('output_path');
83
114
  });