@snap/valdi 1.2.1 → 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 +4 -0
- package/.metadata/.bazelversion.template +1 -1
- package/.metadata/MODULE.bazel.template +48 -6
- 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/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-gestures/skill.md +1 -1
- 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-polyglot-module/skill.md +5 -1
- package/bundled-skills/skills/valdi-tsx/skill.md +6 -6
- package/dist/commands/agentCheck.js +9 -7
- package/dist/commands/bootstrap.js +15 -4
- package/dist/commands/doctor.js +4 -7
- package/dist/commands/install.js +13 -1
- package/dist/commands/newModule.js +8 -1
- package/dist/commands/webHotreload.js +1 -1
- package/dist/core/constants.js +4 -0
- 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/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/package.json +4 -2
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ For complete documentation, see:
|
|
|
56
56
|
- Configures `PATH` and `JAVA_HOME` in your shell profile; asks for `sudo` for package installs and (macOS) the JDK symlink
|
|
57
57
|
- Sets up shell autocomplete
|
|
58
58
|
- The Android SDK/NDK aren't installed; Bazel downloads them during the build
|
|
59
|
-
- Requires Node.js
|
|
59
|
+
- Requires Node.js 20+ and, on macOS, Xcode 26.5 or 27
|
|
60
60
|
|
|
61
61
|
**`valdi doctor`** - Environment diagnostics
|
|
62
62
|
- Validates Node.js, Bazel, Java, Android SDK and adb installations
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -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
|
}
|
|
@@ -119,6 +120,10 @@ function initializeConfigFiles(projectName, template, valdiReleaseTag, valdiWidg
|
|
|
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/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
|
}
|
package/dist/commands/install.js
CHANGED
|
@@ -8,6 +8,7 @@ const BazelClient_1 = require("../utils/BazelClient");
|
|
|
8
8
|
const applicationUtils_1 = require("../utils/applicationUtils");
|
|
9
9
|
const buildInfo_1 = require("../utils/buildInfo");
|
|
10
10
|
const deviceUtils_1 = require("../utils/deviceUtils");
|
|
11
|
+
const iosSimulator_1 = require("../utils/iosSimulator");
|
|
11
12
|
const errorUtils_1 = require("../utils/errorUtils");
|
|
12
13
|
const tempDir_1 = require("../utils/tempDir");
|
|
13
14
|
const logUtils_1 = require("../utils/logUtils");
|
|
@@ -33,7 +34,18 @@ async function valdiInstall(argv) {
|
|
|
33
34
|
}
|
|
34
35
|
case constants_1.PLATFORM.IOS: {
|
|
35
36
|
console.log('Installing iOS application...');
|
|
36
|
-
await
|
|
37
|
+
const developerDir = await (0, iosSimulator_1.getDeveloperDir)();
|
|
38
|
+
if ((0, buildInfo_1.isDeviceBuild)(argv.getArgument('simulator')) || !(0, iosSimulator_1.needsSimctlInstall)(developerDir)) {
|
|
39
|
+
await bazel.runTarget(buildInfo.application, buildInfo.bazelArgs);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const outputFilePath = await argv.getArgumentOrResolve('target_output_path', () => {
|
|
43
|
+
console.log('Resolving output paths...');
|
|
44
|
+
return (0, applicationUtils_1.getOutputFilePath)(bazel, (0, applicationUtils_1.applicationExtensionForPlatform)(buildInfo.platform), buildInfo.application, buildInfo.bazelArgs);
|
|
45
|
+
});
|
|
46
|
+
await bazel.buildTarget(buildInfo.application, buildInfo.bazelArgs);
|
|
47
|
+
await (0, iosSimulator_1.installAndLaunchOnSimulator)(outputFilePath, { deviceId: argv.getArgument('device_id'), developerDir });
|
|
48
|
+
}
|
|
37
49
|
(0, errorUtils_1.logReproduceThisCommandIfNeeded)(argv);
|
|
38
50
|
break;
|
|
39
51
|
}
|
|
@@ -9,6 +9,7 @@ const constants_1 = require("../core/constants");
|
|
|
9
9
|
const errors_1 = require("../core/errors");
|
|
10
10
|
const BazelClient_1 = require("../utils/BazelClient");
|
|
11
11
|
const cliUtils_1 = require("../utils/cliUtils");
|
|
12
|
+
const nonInteractive_1 = require("../utils/nonInteractive");
|
|
12
13
|
const copyBootstrapFiles_1 = require("../utils/copyBootstrapFiles");
|
|
13
14
|
const errorUtils_1 = require("../utils/errorUtils");
|
|
14
15
|
const fileUtils_1 = require("../utils/fileUtils");
|
|
@@ -154,6 +155,11 @@ function getBazelWorkspaceRoot() {
|
|
|
154
155
|
async function valdiNewModule(argv) {
|
|
155
156
|
console.log(referenceString);
|
|
156
157
|
const skipChecks = argv.getArgument('skipChecks');
|
|
158
|
+
(0, nonInteractive_1.requireFlagsWhenNonInteractive)('valdi new_module', [
|
|
159
|
+
{ flag: '--skip-checks', provided: Boolean(skipChecks) },
|
|
160
|
+
{ flag: '--template <type>', provided: Boolean(argv.getArgument('template')) },
|
|
161
|
+
{ flag: '<module-name>', provided: Boolean(argv.getArgument('moduleName')) },
|
|
162
|
+
]);
|
|
157
163
|
const checks = skipChecks ? {} : await promptChecks();
|
|
158
164
|
const valdiModulePath = checks.valdiModulePath ?? path_1.default.join(await getBazelWorkspaceRoot(), 'modules');
|
|
159
165
|
let moduleName = await getModuleName(argv);
|
|
@@ -199,8 +205,9 @@ const builder = (yargs) => {
|
|
|
199
205
|
choices: ALL_MODULE_TEMPLATES.map(template => template.path),
|
|
200
206
|
})
|
|
201
207
|
.option('skip-checks', {
|
|
202
|
-
describe: 'Skips confirmation prompts.',
|
|
208
|
+
describe: 'Skips confirmation prompts. With --template and a module name, runs without any prompt.',
|
|
203
209
|
type: 'boolean',
|
|
210
|
+
alias: 'y',
|
|
204
211
|
});
|
|
205
212
|
};
|
|
206
213
|
exports.builder = builder;
|
|
@@ -16,7 +16,7 @@ async function valdiWebHotreload(argv) {
|
|
|
16
16
|
await client.runTarget(target, '--define enable_web=true');
|
|
17
17
|
}
|
|
18
18
|
exports.command = 'web-hotreload --target <bazel-target>';
|
|
19
|
-
exports.describe = 'Start a Valdi web playground with hot module reload (webpack-dev-server). '
|
|
19
|
+
exports.describe = '(experimental) Start a Valdi web playground with hot module reload (webpack-dev-server). '
|
|
20
20
|
+ 'Pass the Bazel label of the playground :dev target created by '
|
|
21
21
|
+ 'valdi_web_playground(hmr_config = ...).';
|
|
22
22
|
const builder = (yargs) => {
|
package/dist/core/constants.js
CHANGED
|
@@ -48,6 +48,10 @@ var TEMPLATE_BASE_PATHS;
|
|
|
48
48
|
TEMPLATE_BASE_PATHS["AGENTS"] = "AGENTS.md.template";
|
|
49
49
|
TEMPLATE_BASE_PATHS["RULES_PYTHON_PATCH"] = "bzl/patches/rules_python/1.9.0/remove_setuptools_spaces.patch.template";
|
|
50
50
|
TEMPLATE_BASE_PATHS["RULES_PYTHON_PATCH_BUILD"] = "bzl/patches/rules_python/1.9.0/BUILD.bazel.template";
|
|
51
|
+
TEMPLATE_BASE_PATHS["ANDROID_MVN_LOCK"] = "android_mvn_install.json.template";
|
|
52
|
+
TEMPLATE_BASE_PATHS["ANDROID_IDE_COMMON_LOCK"] = "android_ide_common_30_1_3_install.json.template";
|
|
53
|
+
TEMPLATE_BASE_PATHS["MAVEN_LOCK"] = "maven_install.json.template";
|
|
54
|
+
TEMPLATE_BASE_PATHS["RULES_ANDROID_MAVEN_LOCK"] = "rules_android_maven_install.json.template";
|
|
51
55
|
})(TEMPLATE_BASE_PATHS || (exports.TEMPLATE_BASE_PATHS = TEMPLATE_BASE_PATHS = {}));
|
|
52
56
|
exports.VALID_PLATFORMS = [
|
|
53
57
|
PLATFORM.ANDROID,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DevSetupHelper = exports.HOME_DIR = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const errors_1 = require("../core/errors");
|
|
5
6
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
7
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
8
|
const constants_1 = require("../core/constants");
|
|
@@ -36,8 +37,16 @@ class DevSetupHelper {
|
|
|
36
37
|
for (const command of commands) {
|
|
37
38
|
console.log(`- ${command}`);
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
try {
|
|
41
|
+
const result = await (0, cliUtils_1.spawnCliCommand)(command, undefined, 'inherit', false, true);
|
|
42
|
+
return result.stdout;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
const detail = error instanceof Error && error.message ? `\n${error.message}` : '';
|
|
46
|
+
throw new errors_1.CliError(`${guide} failed while running:\n ${commands.join('\n ')}${detail}\n` +
|
|
47
|
+
'If a step asked for a sudo password, re-run this command from an interactive terminal ' +
|
|
48
|
+
'(sudo needs a TTY), or run the failed step manually and then re-run `valdi dev_setup`.');
|
|
49
|
+
}
|
|
41
50
|
}
|
|
42
51
|
async writeEnvVariablesToRcFile(envVariables) {
|
|
43
52
|
const expectedEnvVariable = envVariables.map(e => `export ${e.name}=${e.value}`);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LIBTINFO5_INSTALL_COMMAND = void 0;
|
|
4
|
+
exports.installLibtinfo5 = installLibtinfo5;
|
|
5
|
+
const constants_1 = require("../core/constants");
|
|
6
|
+
const logUtils_1 = require("../utils/logUtils");
|
|
7
|
+
exports.LIBTINFO5_INSTALL_COMMAND = 'sudo apt-get install -y libtinfo5';
|
|
8
|
+
async function installLibtinfo5(shell) {
|
|
9
|
+
try {
|
|
10
|
+
await shell.runShell('Installing libtinfo5 (required for Android tools)', [exports.LIBTINFO5_INSTALL_COMMAND]);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
console.log((0, logUtils_1.wrapInColor)('Warning: libtinfo5 is not available from your package repositories. Some Android command-line tools may not work.', constants_1.ANSI_COLORS.YELLOW_COLOR));
|
|
15
|
+
console.log((0, logUtils_1.wrapInColor)(`Details: ${error instanceof Error ? error.message : 'Unknown error'}`, constants_1.ANSI_COLORS.YELLOW_COLOR));
|
|
16
|
+
console.log((0, logUtils_1.wrapInColor)('On releases that dropped it, enable a repository that still ships libtinfo5 and rerun setup.', constants_1.ANSI_COLORS.YELLOW_COLOR));
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
package/dist/setup/linuxSetup.js
CHANGED
|
@@ -11,6 +11,7 @@ const cliUtils_1 = require("../utils/cliUtils");
|
|
|
11
11
|
const linuxDistro_1 = require("../utils/linuxDistro");
|
|
12
12
|
const logUtils_1 = require("../utils/logUtils");
|
|
13
13
|
const DevSetupHelper_1 = require("./DevSetupHelper");
|
|
14
|
+
const libtinfo5_1 = require("./libtinfo5");
|
|
14
15
|
const BAZELISK_URL = 'https://github.com/bazelbuild/bazelisk/releases/download/v1.26.0/bazelisk-linux-amd64';
|
|
15
16
|
function getDebianArchitecture() {
|
|
16
17
|
const nodeArch = os_1.default.arch();
|
|
@@ -104,28 +105,7 @@ async function linuxSetup() {
|
|
|
104
105
|
}
|
|
105
106
|
})();
|
|
106
107
|
if (!libtinfoInstalled) {
|
|
107
|
-
|
|
108
|
-
const arch = getDebianArchitecture();
|
|
109
|
-
const version = '6.3-2ubuntu0.1';
|
|
110
|
-
const packageName = `libtinfo5_${version}_${arch}.deb`;
|
|
111
|
-
const packageUrl = `https://security.ubuntu.com/ubuntu/pool/universe/n/ncurses/${packageName}`;
|
|
112
|
-
const tempPath = path_1.default.join(DevSetupHelper_1.HOME_DIR, `.valdi/tmp/${packageName}`);
|
|
113
|
-
const tempDir = path_1.default.dirname(tempPath);
|
|
114
|
-
if (!fs_1.default.existsSync(tempDir)) {
|
|
115
|
-
fs_1.default.mkdirSync(tempDir, { recursive: true });
|
|
116
|
-
}
|
|
117
|
-
console.log((0, logUtils_1.wrapInColor)(`Downloading libtinfo5 for ${arch} architecture...`, constants_1.ANSI_COLORS.BLUE_COLOR));
|
|
118
|
-
await devSetup.downloadToPath(packageUrl, tempPath);
|
|
119
|
-
await devSetup.runShell('Installing libtinfo5 (required for Android tools)', [
|
|
120
|
-
`sudo apt install -y ${tempPath}`,
|
|
121
|
-
]);
|
|
122
|
-
fs_1.default.unlinkSync(tempPath);
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
console.log((0, logUtils_1.wrapInColor)('Warning: libtinfo5 installation failed. Some Android command-line tools may not work.', constants_1.ANSI_COLORS.YELLOW_COLOR));
|
|
126
|
-
console.log((0, logUtils_1.wrapInColor)(`Details: ${error instanceof Error ? error.message : 'Unknown error'}`, constants_1.ANSI_COLORS.YELLOW_COLOR));
|
|
127
|
-
console.log((0, logUtils_1.wrapInColor)('You may need to install it manually if you encounter issues.', constants_1.ANSI_COLORS.YELLOW_COLOR));
|
|
128
|
-
}
|
|
108
|
+
await (0, libtinfo5_1.installLibtinfo5)(devSetup);
|
|
129
109
|
}
|
|
130
110
|
}
|
|
131
111
|
else if (distro.type === linuxDistro_1.LinuxDistroType.REDHAT) {
|
|
@@ -92,8 +92,9 @@ class BazelLabel {
|
|
|
92
92
|
get apparentRepo() {
|
|
93
93
|
if (!this.repo)
|
|
94
94
|
return undefined;
|
|
95
|
-
const
|
|
96
|
-
|
|
95
|
+
const repo = this.repo.replace(/^@+/, '');
|
|
96
|
+
const separatorIndex = repo.search(/[~+]/);
|
|
97
|
+
return separatorIndex > 0 ? repo.slice(0, separatorIndex) : repo;
|
|
97
98
|
}
|
|
98
99
|
toString() {
|
|
99
100
|
const repoPrefix = this.repo ? `@${this.repo}` : '';
|
|
@@ -132,10 +133,12 @@ class BazelCommandCache {
|
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
class BazelClient {
|
|
136
|
+
machineOutput;
|
|
135
137
|
workspaceRootCache;
|
|
136
138
|
executionRootCache;
|
|
137
139
|
stableExecArgsCache;
|
|
138
|
-
constructor() {
|
|
140
|
+
constructor(machineOutput = false) {
|
|
141
|
+
this.machineOutput = machineOutput;
|
|
139
142
|
this.workspaceRootCache = new BazelCommandCache(async () => {
|
|
140
143
|
return this.runCommandAndGetTrimmedStdOut('info workspace');
|
|
141
144
|
});
|
|
@@ -248,7 +251,11 @@ class BazelClient {
|
|
|
248
251
|
}
|
|
249
252
|
async spawnCommand(command, stdioMode = DEFAULT_STDIO_MODE, extraArgs = '') {
|
|
250
253
|
const commandWithOptions = getBazelCommandString(command, extraArgs, false);
|
|
251
|
-
|
|
254
|
+
const log = this.machineOutput ? console.error : console.log;
|
|
255
|
+
log(`${(0, logUtils_1.wrapInColor)('Running Bazel command:', constants_1.ANSI_COLORS.YELLOW_COLOR)} ${getBazelCli()} ${command} ${extraArgs}`);
|
|
256
|
+
if (this.machineOutput && stdioMode === 'inherit') {
|
|
257
|
+
stdioMode = ['ignore', 2, 2];
|
|
258
|
+
}
|
|
252
259
|
return await (0, cliUtils_1.spawnCliCommand)(commandWithOptions, undefined, stdioMode, true, true);
|
|
253
260
|
}
|
|
254
261
|
async resolveTarget(pathStr) {
|
package/dist/utils/errorUtils.js
CHANGED
|
@@ -11,7 +11,7 @@ function parseGitHubRepoSlug(repoUrl) {
|
|
|
11
11
|
}
|
|
12
12
|
return `${match[1]}/${match[2]}`;
|
|
13
13
|
}
|
|
14
|
-
const LATEST_RELEASE_HINT = 'Use --valdiVersion=latest to retry, or --valdiVersion=<tag> (e.g. main or
|
|
14
|
+
const LATEST_RELEASE_HINT = 'Use --valdiVersion=latest to retry, or --valdiVersion=<tag> (e.g. main or 1.0.0) to pin a version.';
|
|
15
15
|
async function getLatestReleaseTag(repoUrl) {
|
|
16
16
|
const slug = parseGitHubRepoSlug(repoUrl);
|
|
17
17
|
let response;
|