@snap/valdi 1.2.0 → 1.3.0
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.
- package/.bootstrap/modules/ui_component/BUILD.bazel.template +1 -1
- package/.metadata/.bazelrc.template +5 -5
- package/.metadata/.bazelversion.template +1 -1
- package/.metadata/AGENTS.md.template +7 -0
- package/.metadata/MODULE.bazel.template +75 -6
- package/.metadata/README.md.template +2 -2
- package/.metadata/android_ide_common_30_1_3_install.json.template +1818 -0
- package/.metadata/android_mvn_install.json.template +2877 -0
- package/.metadata/maven_install.json.template +444 -0
- package/.metadata/rules_android_maven_install.json.template +4879 -0
- package/.metadata/skill-tests-README.md.template +1 -1
- package/README.md +12 -13
- package/bundled-skills/skills/valdi-async/tests/README.md +1 -1
- package/bundled-skills/skills/valdi-compiler/skill.md +3 -8
- package/bundled-skills/skills/valdi-component-tests/skill.md +1 -1
- package/bundled-skills/skills/valdi-component-tests/tests/README.md +1 -1
- package/bundled-skills/skills/valdi-custom-view/skill.md +1 -1
- package/bundled-skills/skills/valdi-gestures/skill.md +1 -1
- package/bundled-skills/skills/valdi-migrate/tests/README.md +2 -2
- package/bundled-skills/skills/valdi-mock-breakdown/skill.md +1 -1
- package/bundled-skills/skills/valdi-mock-to-module/scripts/find_icon.py +8 -8
- package/bundled-skills/skills/valdi-mock-to-module/scripts/test_find_icon.py +2 -2
- package/bundled-skills/skills/valdi-perf/skill.md +2 -2
- package/bundled-skills/skills/valdi-perf/tests/README.md +1 -1
- package/bundled-skills/skills/valdi-polyglot-module/skill.md +5 -1
- package/bundled-skills/skills/valdi-tsx/skill.md +6 -6
- package/bundled-skills/skills/valdi-tsx/tests/README.md +1 -1
- package/dist/commands/agentCheck.js +9 -7
- package/dist/commands/bootstrap.js +16 -5
- package/dist/commands/build.js +7 -1
- package/dist/commands/doctor.js +4 -7
- package/dist/commands/export.js +47 -16
- package/dist/commands/hotreload.js +247 -27
- package/dist/commands/install.js +92 -3
- package/dist/commands/newModule.js +8 -1
- package/dist/commands/webHotreload.js +3 -3
- package/dist/core/constants.js +17 -2
- package/dist/setup/DevSetupHelper.js +11 -2
- package/dist/setup/libtinfo5.js +19 -0
- package/dist/setup/linuxSetup.js +2 -22
- package/dist/utils/BazelClient.js +11 -4
- package/dist/utils/applicationUtils.js +17 -2
- package/dist/utils/buildInfo.js +5 -1
- package/dist/utils/cliUtils.js +2 -2
- package/dist/utils/directorySync.js +153 -0
- package/dist/utils/errorUtils.js +1 -1
- package/dist/utils/githubUtils.js +1 -1
- package/dist/utils/iosSimulator.js +136 -0
- package/dist/utils/nonInteractive.js +13 -0
- package/dist/utils/prettierCheck.js +19 -0
- package/dist/utils/processUtils.js +14 -0
- package/dist/utils/webApplicationSession.js +58 -0
- package/dist/utils/webHotReloadSession.js +212 -0
- package/dist/utils/webServerUtils.js +195 -0
- package/dist/utils/zipUtils.js +20 -2
- package/package.json +4 -2
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
|
|
56
|
-
- Configures
|
|
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
|
-
-
|
|
58
|
+
- The Android SDK/NDK aren't installed; Bazel downloads them during the build
|
|
59
|
+
- Requires Node.js 20+ 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
|
|
74
|
-
-
|
|
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
|
|
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
|
-
├──
|
|
127
|
+
├── MODULE.bazel # Bazel module (dependencies)
|
|
129
128
|
├── BUILD.bazel # Bazel build
|
|
130
129
|
└── modules/
|
|
131
130
|
├── module_a/
|
|
@@ -59,18 +59,13 @@ Tests are critical - add tests for new features and error cases. Run the test su
|
|
|
59
59
|
|
|
60
60
|
## Build
|
|
61
61
|
|
|
62
|
-
### Using
|
|
62
|
+
### Using Bazel (recommended):
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
|
-
|
|
66
|
-
./scripts/update_compiler_bazel.sh -o bin/compiler
|
|
65
|
+
bazel build //compiler/compiler:local_valdi_compiler
|
|
67
66
|
```
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
- Builds the compiler with Bazel (`//compiler/compiler:local_valdi_compiler`); no Swift toolchain install is required
|
|
71
|
-
- Builds the compiler for the correct architecture (on macOS, lipos arm64 + x86_64 into a universal binary and codesigns it)
|
|
72
|
-
- Copies the binary to `bin/compiler/macos/valdi_compiler` (or `linux/valdi_compiler`)
|
|
73
|
-
- Handles platform differences (macOS vs Linux)
|
|
68
|
+
There are no prebuilt compiler binaries: the compiler is built from source only, and Bazel rebuilds it as part of normal builds when its sources change. No Swift toolchain install is required.
|
|
74
69
|
|
|
75
70
|
### Alternative: Using Xcode
|
|
76
71
|
|
|
@@ -26,7 +26,7 @@ Good candidates for keys:
|
|
|
26
26
|
- A spinner shown in a loading/saving state of a union type
|
|
27
27
|
|
|
28
28
|
Do NOT add keys to:
|
|
29
|
-
- Elements with hardcoded asset values (e.g., `src={
|
|
29
|
+
- Elements with hardcoded asset values (e.g., `src={HeliosIcon.xSignStroke}`)
|
|
30
30
|
- Label elements with always-present localized strings
|
|
31
31
|
- Elements that are always rendered the same regardless of view model
|
|
32
32
|
|
|
@@ -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`
|
|
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
|
|
|
@@ -131,7 +131,7 @@ Expand the tappable area beyond the visible bounds:
|
|
|
131
131
|
touchAreaExtension={10} // extends hit area by 10pt in each direction
|
|
132
132
|
width={24} height={24}
|
|
133
133
|
>
|
|
134
|
-
<image src={
|
|
134
|
+
<image src={HeliosIcon.checkmarkFill} />
|
|
135
135
|
</view>
|
|
136
136
|
```
|
|
137
137
|
|
|
@@ -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
|
|
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
|
|
60
|
+
cd <valdi-repo-root>
|
|
61
61
|
bazel build //ai-skills/skills/valdi-migrate/tests:tests
|
|
62
62
|
```
|
|
63
63
|
|
|
@@ -52,7 +52,7 @@ Start with primitives to get a bare-bones skeleton on screen fast:
|
|
|
52
52
|
| `<image>` | Images, icons (use `src` prop with Asset) |
|
|
53
53
|
| `<scroll>` | Scrollable content areas |
|
|
54
54
|
| `<shape>` | Rounded rects, circles, dividers, decorative shapes |
|
|
55
|
-
| `<
|
|
55
|
+
| `<view onTap={...}>` | Tappable areas (there is no `<button>` element) |
|
|
56
56
|
|
|
57
57
|
### Then upgrade to widget library components (if available)
|
|
58
58
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""Fuzzy icon finder for Valdi's
|
|
2
|
+
"""Fuzzy icon finder for Valdi's HeliosIcon library.
|
|
3
3
|
|
|
4
|
-
Parses icon names from
|
|
4
|
+
Parses icon names from HeliosIcons.tsx and performs fuzzy matching against
|
|
5
5
|
a search query. Uses word overlap, substring matching, and a synonym
|
|
6
6
|
map to find relevant icons.
|
|
7
7
|
|
|
8
8
|
Usage:
|
|
9
|
-
python3 find_icon.py "chat bubble" --icons-file /path/to/
|
|
9
|
+
python3 find_icon.py "chat bubble" --icons-file /path/to/HeliosIcons.tsx
|
|
10
10
|
python3 find_icon.py "settings"
|
|
11
11
|
python3 find_icon.py "arrow right share"
|
|
12
12
|
"""
|
|
@@ -46,7 +46,7 @@ SYNONYMS = {
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
def parse_icons(filepath: str) -> List[str]:
|
|
49
|
-
"""Parse icon getter names from
|
|
49
|
+
"""Parse icon getter names from HeliosIcons.tsx."""
|
|
50
50
|
pattern = re.compile(r"static get (\w+)\(\): Asset")
|
|
51
51
|
icons = []
|
|
52
52
|
with open(filepath, "r") as f:
|
|
@@ -220,7 +220,7 @@ def find_icons(query: str, icons_file: str, top_n: int = 5) -> List[Tuple[str, f
|
|
|
220
220
|
|
|
221
221
|
|
|
222
222
|
def find_default_icons_file() -> str:
|
|
223
|
-
"""Try to find
|
|
223
|
+
"""Try to find HeliosIcons.tsx in common locations."""
|
|
224
224
|
patterns = [
|
|
225
225
|
# Common icon library locations
|
|
226
226
|
"**/src/components/icon/*Icons.tsx",
|
|
@@ -235,13 +235,13 @@ def find_default_icons_file() -> str:
|
|
|
235
235
|
|
|
236
236
|
def main():
|
|
237
237
|
parser = argparse.ArgumentParser(
|
|
238
|
-
description="Fuzzy icon finder for Valdi
|
|
238
|
+
description="Fuzzy icon finder for Valdi HeliosIcon library"
|
|
239
239
|
)
|
|
240
240
|
parser.add_argument("query", help="Search query (e.g. 'chat bubble', 'settings', 'arrow right')")
|
|
241
241
|
parser.add_argument(
|
|
242
242
|
"--icons-file",
|
|
243
243
|
default="",
|
|
244
|
-
help="Path to
|
|
244
|
+
help="Path to HeliosIcons.tsx (auto-detected if not provided)",
|
|
245
245
|
)
|
|
246
246
|
parser.add_argument(
|
|
247
247
|
"--top",
|
|
@@ -260,7 +260,7 @@ def main():
|
|
|
260
260
|
if not icons_file:
|
|
261
261
|
icons_file = find_default_icons_file()
|
|
262
262
|
if not icons_file:
|
|
263
|
-
print("Error: Could not find
|
|
263
|
+
print("Error: Could not find HeliosIcons.tsx. Please provide --icons-file.", file=sys.stderr)
|
|
264
264
|
sys.exit(1)
|
|
265
265
|
|
|
266
266
|
results = find_icons(args.query, icons_file, args.top)
|
|
@@ -98,7 +98,7 @@ class TestParseIcons(unittest.TestCase):
|
|
|
98
98
|
def test_parses_static_getters(self):
|
|
99
99
|
with tempfile.NamedTemporaryFile(mode='w', suffix='.tsx', delete=False) as f:
|
|
100
100
|
f.write("""
|
|
101
|
-
export class
|
|
101
|
+
export class HeliosIcon {
|
|
102
102
|
static get chatBubbleFill(): Asset { return Asset.fromModule('sig_chat_bubble_fill'); }
|
|
103
103
|
static get gearFill(): Asset { return Asset.fromModule('sig_gear_fill'); }
|
|
104
104
|
static get bellStroke(): Asset { return Asset.fromModule('sig_bell_stroke'); }
|
|
@@ -122,7 +122,7 @@ class TestFindIcons(unittest.TestCase):
|
|
|
122
122
|
def setUp(self):
|
|
123
123
|
self.icons_file = tempfile.NamedTemporaryFile(mode='w', suffix='.tsx', delete=False)
|
|
124
124
|
self.icons_file.write("""
|
|
125
|
-
export class
|
|
125
|
+
export class HeliosIcon {
|
|
126
126
|
static get chatBubbleFill(): Asset { return Asset.fromModule('a'); }
|
|
127
127
|
static get chatBubbleStroke(): Asset { return Asset.fromModule('b'); }
|
|
128
128
|
static get gearFill(): Asset { return Asset.fromModule('c'); }
|
|
@@ -419,8 +419,8 @@ first access and caches it thereafter — no `await`, no render-path tick.
|
|
|
419
419
|
```typescript
|
|
420
420
|
import { lazyImport } from 'valdi_core/src/LazyImport';
|
|
421
421
|
|
|
422
|
-
//
|
|
423
|
-
const heavy = lazyImport<typeof import('./HeavyUtil')>(require
|
|
422
|
+
// The loader runs in this module, so the relative path resolves from here.
|
|
423
|
+
const heavy = lazyImport<typeof import('./HeavyUtil')>(() => require('./HeavyUtil', true));
|
|
424
424
|
|
|
425
425
|
// First `.get` parses + initialises the module; later reads are cached.
|
|
426
426
|
heavy.get.doWork();
|
|
@@ -62,9 +62,10 @@ Web entry files export view factories that are auto-registered with the `WebView
|
|
|
62
62
|
```typescript
|
|
63
63
|
interface AttributeHandler {
|
|
64
64
|
changeAttribute(name: string, value: unknown): void;
|
|
65
|
+
destroy?(): void;
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
type ViewFactory = (container: HTMLElement) => AttributeHandler;
|
|
68
|
+
type ViewFactory = (container: HTMLElement) => AttributeHandler | void;
|
|
68
69
|
|
|
69
70
|
function createMyViewFactory(): ViewFactory {
|
|
70
71
|
return (container: HTMLElement): AttributeHandler => {
|
|
@@ -77,6 +78,9 @@ function createMyViewFactory(): ViewFactory {
|
|
|
77
78
|
element.textContent = String(value);
|
|
78
79
|
}
|
|
79
80
|
},
|
|
81
|
+
destroy(): void {
|
|
82
|
+
element.remove();
|
|
83
|
+
},
|
|
80
84
|
};
|
|
81
85
|
};
|
|
82
86
|
}
|
|
@@ -42,7 +42,9 @@ class MyComponent extends StatefulComponent<ViewModel, State> {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
onRender() { // Returns void, not JSX!
|
|
45
|
-
<
|
|
45
|
+
<view onTap={this.handleClick}>
|
|
46
|
+
<label value={`Count: ${this.state.count}`} />
|
|
47
|
+
</view>;
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
```
|
|
@@ -94,8 +96,6 @@ const MyComponentWithProvider = withProviders(MyServiceProvider)(MyComponent);
|
|
|
94
96
|
<label value="Click me" />
|
|
95
97
|
</view>
|
|
96
98
|
|
|
97
|
-
<button title="Press me" onPress={this.handleAction} />
|
|
98
|
-
|
|
99
99
|
// ❌ WRONG - No global keyboard events
|
|
100
100
|
window.addEventListener('keydown', ...); // Doesn't work!
|
|
101
101
|
document.addEventListener('click', ...); // Doesn't work!
|
|
@@ -116,7 +116,7 @@ document.addEventListener('click', ...); // Doesn't work!
|
|
|
116
116
|
)}
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
**Important**: Valdi doesn't support `addEventListener`, `keydown`, or other global DOM events. Use element-specific callbacks like `onTap`, `
|
|
119
|
+
**Important**: Valdi doesn't support `addEventListener`, `keydown`, or other global DOM events. Use element-specific callbacks like `onTap`, `onChange`, etc. For keyboard input on macOS desktop, use a polyglot `<custom-view>` with a native NSView that captures `keyDown:` events and forwards them via a bound callback attribute.
|
|
120
120
|
|
|
121
121
|
## Timers and Scheduling
|
|
122
122
|
|
|
@@ -426,12 +426,12 @@ interface GameState {
|
|
|
426
426
|
3. **Using this.props** - Should be this.viewModel
|
|
427
427
|
4. **Wrong lifecycle names** - onCreate/onViewModelUpdate/onDestroy (not mount/update/unmount)
|
|
428
428
|
5. **Suggesting scheduleRender()** - Deprecated, use StatefulComponent + setState()
|
|
429
|
-
6. **Using addEventListener** - Use element callbacks like onTap,
|
|
429
|
+
6. **Using addEventListener** - Use element callbacks like onTap, onChange
|
|
430
430
|
7. **Using setInterval/setTimeout directly** - Use this.setTimeoutDisposable()
|
|
431
431
|
8. **Using CSS properties that don't exist** - No paddingHorizontal, paddingVertical, paddingInline. (`gap`/`rowGap`/`columnGap` DO now exist (Yoga upgrade), though margins remain the common way children are spaced in existing code.)
|
|
432
432
|
9. **Using `flex: 1`** - `flex` doesn't exist on `View`; use `flexGrow: 1` instead
|
|
433
433
|
10. **Using `fontSize` on Label** - Labels use `font: 'system 20'` (string), not `fontSize`
|
|
434
|
-
11. **Typing
|
|
434
|
+
11. **Typing HeliosIcon values as `string`** - `HeliosIcon.cameraStroke` etc. return `Asset`, not `string`; use `import { Asset } from 'valdi_core/src/Asset'` for ViewModel fields that store icon references
|
|
435
435
|
12. **Using `overflow: 'hidden'`** - `View` only accepts `'visible' | 'scroll'`; remove overflow or use 'scroll'
|
|
436
436
|
13. **Using type aliases in `@ExportModel` ViewModels** - Only primitives and other `@ExportModel` types are allowed
|
|
437
437
|
14. **Importing `Shape` instead of `ShapeView`** - `Shape` is not exported; use `import { ShapeView } from 'valdi_tsx/src/NativeTemplateElements'` and `new Style<ShapeView>({...})`
|
|
@@ -39,7 +39,7 @@ async function getTestTargets(client, module) {
|
|
|
39
39
|
async function valdiAgentCheck(argv) {
|
|
40
40
|
const json = argv.getArgument('json') ?? false;
|
|
41
41
|
const quick = argv.getArgument('quick') ?? false;
|
|
42
|
-
const bazelClient = new BazelClient_1.BazelClient();
|
|
42
|
+
const bazelClient = new BazelClient_1.BazelClient(json);
|
|
43
43
|
const moduleName = argv.getArgument('module');
|
|
44
44
|
const targetName = argv.getArgument('target');
|
|
45
45
|
if (!moduleName && !targetName) {
|
|
@@ -90,8 +90,8 @@ async function valdiAgentCheck(argv) {
|
|
|
90
90
|
}
|
|
91
91
|
const lintPromise = (buildTargets.length > 0)
|
|
92
92
|
? runStep('Lint check', async () => {
|
|
93
|
-
const { runCliCommand } = await Promise.resolve().then(() => __importStar(require('../utils/cliUtils')));
|
|
94
93
|
const { globSync } = await Promise.resolve().then(() => __importStar(require('glob')));
|
|
94
|
+
const { runPrettierCheck } = await Promise.resolve().then(() => __importStar(require('../utils/prettierCheck')));
|
|
95
95
|
const firstTarget = buildTargets[0] ?? '';
|
|
96
96
|
const packagePath = firstTarget.replace(/^\/\//, '').replace(/:.*$/, '') || '.';
|
|
97
97
|
const globPattern = `${packagePath}/**/*.{ts,tsx}`;
|
|
@@ -99,9 +99,12 @@ async function valdiAgentCheck(argv) {
|
|
|
99
99
|
if (tsFiles.length === 0) {
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
const result = await
|
|
103
|
-
if (result.
|
|
104
|
-
throw new Error(
|
|
102
|
+
const result = await runPrettierCheck(globPattern);
|
|
103
|
+
if (result.status === 'unformatted') {
|
|
104
|
+
throw new Error(`Lint check failed — files not formatted\n${result.output}`);
|
|
105
|
+
}
|
|
106
|
+
else if (result.status === 'error') {
|
|
107
|
+
throw new Error(`Lint check could not run prettier\n${result.output}`);
|
|
105
108
|
}
|
|
106
109
|
}, json)
|
|
107
110
|
: Promise.resolve({ name: 'Lint check', status: 'skip', durationMs: 0, message: 'No targets resolved for lint' });
|
|
@@ -143,7 +146,6 @@ function outputResults(results, totalStart, json) {
|
|
|
143
146
|
console.log(` Total: ${totalDurationMs}ms`);
|
|
144
147
|
if (failed > 0) {
|
|
145
148
|
console.log((0, logUtils_1.wrapInColor)('\n✗ Agent check FAILED', constants_1.ANSI_COLORS.RED_COLOR));
|
|
146
|
-
process.exitCode = 1;
|
|
147
149
|
}
|
|
148
150
|
else {
|
|
149
151
|
console.log((0, logUtils_1.wrapInColor)('\n✓ Agent check PASSED', constants_1.ANSI_COLORS.GREEN_COLOR));
|
|
@@ -154,7 +156,7 @@ function outputResults(results, totalStart, json) {
|
|
|
154
156
|
}
|
|
155
157
|
}
|
|
156
158
|
exports.command = 'agent-check [--module module_name] [--target target_name] [--quick]';
|
|
157
|
-
exports.describe = 'Validate a Valdi module: resolve targets, build, lint, and test in one command. '
|
|
159
|
+
exports.describe = '(experimental) Validate a Valdi module: resolve targets, build, lint, and test in one command. '
|
|
158
160
|
+ 'Use --quick to skip the build step when the hot reloader is already compiling your changes. '
|
|
159
161
|
+ 'Use --json for structured output that AI agents can parse directly.';
|
|
160
162
|
const builder = (yargs) => {
|
|
@@ -16,6 +16,7 @@ const logUtils_1 = require("../utils/logUtils");
|
|
|
16
16
|
const stringUtils_1 = require("../utils/stringUtils");
|
|
17
17
|
const projectsync_1 = require("./projectsync");
|
|
18
18
|
const githubUtils_1 = require("../utils/githubUtils");
|
|
19
|
+
const nonInteractive_1 = require("../utils/nonInteractive");
|
|
19
20
|
const ALL_APPLICATION_TEMPLATES = [
|
|
20
21
|
{
|
|
21
22
|
name: 'UI Application',
|
|
@@ -30,8 +31,8 @@ const ALL_APPLICATION_TEMPLATES = [
|
|
|
30
31
|
];
|
|
31
32
|
const VALDI_GIT_URL = 'https://github.com/Snapchat/Valdi';
|
|
32
33
|
const VALDI_WIDGETS_GIT_URL = 'https://github.com/Snapchat/Valdi_Widgets';
|
|
33
|
-
const DEFAULT_VALDI_RELEASE_TAG = '
|
|
34
|
-
const DEFAULT_VALDI_WIDGETS_RELEASE_TAG = '
|
|
34
|
+
const DEFAULT_VALDI_RELEASE_TAG = '1.0.0';
|
|
35
|
+
const DEFAULT_VALDI_WIDGETS_RELEASE_TAG = '1.0.0';
|
|
35
36
|
function isAlreadyInitialized() {
|
|
36
37
|
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
38
|
}
|
|
@@ -112,13 +113,17 @@ function initializeConfigFiles(projectName, template, valdiReleaseTag, valdiWidg
|
|
|
112
113
|
fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.BAZEL_RC).withReplacements({
|
|
113
114
|
VALDI_RELEASE_TAG: valdiReleaseTag,
|
|
114
115
|
}),
|
|
115
|
-
fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.README),
|
|
116
|
+
fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.README).withReplacements({ PROJECT_NAME: projectName }),
|
|
116
117
|
fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.GIT_IGNORE),
|
|
117
118
|
fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.WATCHMAN_CONFIG),
|
|
118
119
|
fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.EDITOR_CONFIG),
|
|
119
120
|
fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.AGENTS).withReplacements({ MODULE_NAME: projectName }),
|
|
120
121
|
fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.RULES_PYTHON_PATCH_BUILD),
|
|
121
122
|
fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.RULES_PYTHON_PATCH),
|
|
123
|
+
fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.ANDROID_MVN_LOCK),
|
|
124
|
+
fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.ANDROID_IDE_COMMON_LOCK),
|
|
125
|
+
fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.MAVEN_LOCK),
|
|
126
|
+
fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.RULES_ANDROID_MAVEN_LOCK),
|
|
122
127
|
];
|
|
123
128
|
TEMPLATE_FILES.forEach(templateFile => {
|
|
124
129
|
console.log((0, logUtils_1.wrapInColor)(`Creating ${templateFile.baseName} in ${templateFile.outputPath}...`, constants_1.ANSI_COLORS.YELLOW_COLOR));
|
|
@@ -174,6 +179,11 @@ function applyLocalOverrides(localValdiPath) {
|
|
|
174
179
|
async function valdiBootstrap(argv) {
|
|
175
180
|
const curDir = process.cwd();
|
|
176
181
|
console.log(`\nCurrent directory: ${(0, logUtils_1.wrapInColor)(curDir, constants_1.ANSI_COLORS.GREEN_COLOR)}`);
|
|
182
|
+
(0, nonInteractive_1.requireFlagsWhenNonInteractive)('valdi bootstrap', [
|
|
183
|
+
{ flag: '-y', provided: Boolean(argv.getArgument('confirmBootstrap')) },
|
|
184
|
+
{ flag: '-n <project-name>', provided: Boolean(argv.getArgument('projectName')) },
|
|
185
|
+
{ flag: '-t <application-type>', provided: Boolean(argv.getArgument('applicationType')) },
|
|
186
|
+
]);
|
|
177
187
|
if (isAlreadyInitialized()) {
|
|
178
188
|
if (argv.getArgument('withCleanup')) {
|
|
179
189
|
console.log((0, logUtils_1.wrapInColor)('Deleting all files in current directory...', constants_1.ANSI_COLORS.YELLOW_COLOR));
|
|
@@ -236,7 +246,8 @@ const builder = (yargs) => {
|
|
|
236
246
|
alias: 'y',
|
|
237
247
|
})
|
|
238
248
|
.option('applicationType', {
|
|
239
|
-
describe:
|
|
249
|
+
describe: `Type of application to create (${ALL_APPLICATION_TEMPLATES.map(t => t.path).join(', ')})`,
|
|
250
|
+
choices: ALL_APPLICATION_TEMPLATES.map(t => t.path),
|
|
240
251
|
alias: 't',
|
|
241
252
|
})
|
|
242
253
|
.option('projectName', {
|
|
@@ -245,7 +256,7 @@ const builder = (yargs) => {
|
|
|
245
256
|
alias: 'n',
|
|
246
257
|
})
|
|
247
258
|
.option('valdiVersion', {
|
|
248
|
-
describe: `Valdi release tag or branch to use (e.g.
|
|
259
|
+
describe: `Valdi release tag or branch to use (e.g. 1.0.0, main). Use "latest" for the GitHub latest release, or "main" for bleeding edge. Default: ${DEFAULT_VALDI_RELEASE_TAG}`,
|
|
249
260
|
type: 'string',
|
|
250
261
|
})
|
|
251
262
|
.option('valdiWidgetsVersion', {
|
package/dist/commands/build.js
CHANGED
|
@@ -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: '
|
|
75
|
+
describe: 'Build for the iOS simulator (default). Pass --no-simulator to build for a device',
|
|
70
76
|
type: 'boolean',
|
|
71
77
|
});
|
|
72
78
|
});
|
package/dist/commands/doctor.js
CHANGED
|
@@ -140,28 +140,25 @@ class ValdiDoctor {
|
|
|
140
140
|
throw new Error('Invalid version format');
|
|
141
141
|
}
|
|
142
142
|
const majorVersion = Number.parseInt(majorVersionStr, 10);
|
|
143
|
-
if (majorVersion >=
|
|
143
|
+
if (majorVersion >= 20) {
|
|
144
144
|
this.addResult({
|
|
145
145
|
name: 'Node.js version',
|
|
146
146
|
status: 'pass',
|
|
147
147
|
message: `Node.js ${version} is installed`,
|
|
148
148
|
category: 'Node.js installation',
|
|
149
149
|
});
|
|
150
|
-
if (this.autoFix && majorVersion < 20) {
|
|
151
|
-
await this.attemptAutoFix('node', 'nvm install 20 && nvm use 20');
|
|
152
|
-
}
|
|
153
150
|
}
|
|
154
151
|
else {
|
|
155
152
|
this.addResult({
|
|
156
153
|
name: 'Node.js version',
|
|
157
154
|
status: 'fail',
|
|
158
|
-
message: `Node.js ${version} is outdated. Valdi requires Node.js
|
|
155
|
+
message: `Node.js ${version} is outdated. Valdi requires Node.js 20 or higher`,
|
|
159
156
|
fixable: true,
|
|
160
|
-
fixCommand: 'nvm install
|
|
157
|
+
fixCommand: 'nvm install 20 && nvm use 20',
|
|
161
158
|
category: 'Node.js installation',
|
|
162
159
|
});
|
|
163
160
|
if (this.autoFix) {
|
|
164
|
-
await this.attemptAutoFix('node', 'nvm install
|
|
161
|
+
await this.attemptAutoFix('node', 'nvm install 20 && nvm use 20');
|
|
165
162
|
}
|
|
166
163
|
}
|
|
167
164
|
}
|