@snap/valdi 1.0.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.
- package/.bazelignore +2 -0
- package/.bootstrap/apps/cli_application/AGENTS.md.template +215 -0
- package/.bootstrap/apps/cli_application/BUILD.bazel.template +7 -0
- package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +11 -0
- package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/src/index.ts +1 -0
- package/.bootstrap/apps/ui_application/.eslint.rc +27 -0
- package/.bootstrap/apps/ui_application/AGENTS.md.template +202 -0
- package/.bootstrap/apps/ui_application/BUILD.bazel.template +19 -0
- package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +21 -0
- package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/res/valdi@3x.png +0 -0
- package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/src/App.tsx +133 -0
- package/.bootstrap/apps/ui_application/package.json +24 -0
- package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +21 -0
- package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +29 -0
- package/.bootstrap/modules/cpp_bridge_module/src/Calculator.d.ts +1 -0
- package/.bootstrap/modules/ios_android_bridge_module/BUILD.bazel.template +39 -0
- package/.bootstrap/modules/ios_android_bridge_module/android/CalculatorModuleFactory.kt.template +18 -0
- package/.bootstrap/modules/ios_android_bridge_module/ios/SCCCalculatorModuleFactory.m.template +31 -0
- package/.bootstrap/modules/ios_android_bridge_module/src/Calculator.d.ts +4 -0
- package/.bootstrap/modules/ios_android_view_module/BUILD.bazel.template +41 -0
- package/.bootstrap/modules/ios_android_view_module/android/CircleView.kt.template +42 -0
- package/.bootstrap/modules/ios_android_view_module/android/CircleViewAttributesBinder.kt.template +60 -0
- package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.h +6 -0
- package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.m +82 -0
- package/.bootstrap/modules/ios_android_view_module/src/Circle.tsx.template +15 -0
- package/.bootstrap/modules/ui_component/BUILD.bazel.template +34 -0
- package/.bootstrap/modules/ui_component/src/NewModuleComponent.tsx +45 -0
- package/.config/copyconfig.json +10 -0
- package/.editorconfig +21 -0
- package/.eslintignore +1 -0
- package/.eslintrc.js +72 -0
- package/.metadata/.bazelrc.template +91 -0
- package/.metadata/.bazelversion.template +1 -0
- package/.metadata/.eslintrc.js.template +27 -0
- package/.metadata/.gitignore.template +4 -0
- package/.metadata/.prettierrc.json.template +7 -0
- package/.metadata/.watchmanconfig.template +8 -0
- package/.metadata/README.md.template +31 -0
- package/.metadata/WORKSPACE.template +57 -0
- package/.metadata/config.yaml.template +1 -0
- package/.metadata/package.json.template +23 -0
- package/.prettierignore +2 -0
- package/.prettierrc.json +7 -0
- package/README.md +123 -0
- package/dist/commands/bootstrap.js +233 -0
- package/dist/commands/build.js +67 -0
- package/dist/commands/devSetup.js +18 -0
- package/dist/commands/doctor.js +892 -0
- package/dist/commands/export.js +84 -0
- package/dist/commands/hotreload.js +89 -0
- package/dist/commands/install.js +71 -0
- package/dist/commands/lint.js +18 -0
- package/dist/commands/lint_commands/lintCheck.js +31 -0
- package/dist/commands/lint_commands/lintFormat.js +31 -0
- package/dist/commands/log.js +84 -0
- package/dist/commands/newModule.js +208 -0
- package/dist/commands/package.js +66 -0
- package/dist/commands/projectsync.js +316 -0
- package/dist/commands/test.js +54 -0
- package/dist/core/constants.js +76 -0
- package/dist/core/errors.js +12 -0
- package/dist/index.js +22 -0
- package/dist/setup/DevSetupHelper.js +146 -0
- package/dist/setup/linuxSetup.js +31 -0
- package/dist/setup/macOSSetup.js +35 -0
- package/dist/setup/setupEntryPoint.js +56 -0
- package/dist/setup/versions.js +8 -0
- package/dist/utils/ArgumentsResolver.js +23 -0
- package/dist/utils/BazelClient.js +219 -0
- package/dist/utils/Digraph.js +71 -0
- package/dist/utils/LoadingIndicator.js +38 -0
- package/dist/utils/applicationUtils.js +201 -0
- package/dist/utils/buildInfo.js +60 -0
- package/dist/utils/byString.js +6 -0
- package/dist/utils/cliUtils.js +93 -0
- package/dist/utils/copyBootstrapFiles.js +26 -0
- package/dist/utils/deviceUtils.js +72 -0
- package/dist/utils/errorUtils.js +55 -0
- package/dist/utils/fileUtils.js +204 -0
- package/dist/utils/githubUtils.js +8 -0
- package/dist/utils/jsonUtils.js +28 -0
- package/dist/utils/lintUtils.js +149 -0
- package/dist/utils/logUtils.js +8 -0
- package/dist/utils/pathUtils.js +12 -0
- package/dist/utils/stringUtils.js +17 -0
- package/dist/utils/stringUtils.spec.js +18 -0
- package/dist/utils/tempDir.js +26 -0
- package/dist/utils/zipUtils.js +16 -0
- package/package.json +51 -0
- package/prettier.config.js +4 -0
- package/spec/support/jasmine.json +6 -0
- package/src/commands/bootstrap.ts +317 -0
- package/src/commands/build.ts +89 -0
- package/src/commands/devSetup.ts +17 -0
- package/src/commands/doctor.ts +1422 -0
- package/src/commands/export.ts +131 -0
- package/src/commands/hotreload.ts +108 -0
- package/src/commands/install.ts +93 -0
- package/src/commands/lint.ts +15 -0
- package/src/commands/lint_commands/lintCheck.ts +53 -0
- package/src/commands/lint_commands/lintFormat.ts +49 -0
- package/src/commands/log.ts +108 -0
- package/src/commands/newModule.ts +287 -0
- package/src/commands/package.ts +102 -0
- package/src/commands/projectsync.ts +488 -0
- package/src/commands/test.ts +68 -0
- package/src/core/constants.ts +95 -0
- package/src/core/errors.ts +10 -0
- package/src/index.ts +22 -0
- package/src/setup/DevSetupHelper.ts +188 -0
- package/src/setup/linuxSetup.ts +38 -0
- package/src/setup/macOSSetup.ts +42 -0
- package/src/setup/setupEntryPoint.ts +64 -0
- package/src/setup/versions.ts +8 -0
- package/src/utils/ArgumentsResolver.ts +23 -0
- package/src/utils/BazelClient.ts +285 -0
- package/src/utils/Digraph.ts +81 -0
- package/src/utils/LoadingIndicator.ts +43 -0
- package/src/utils/applicationUtils.ts +276 -0
- package/src/utils/buildInfo.ts +99 -0
- package/src/utils/byString.ts +3 -0
- package/src/utils/cliUtils.ts +112 -0
- package/src/utils/copyBootstrapFiles.ts +30 -0
- package/src/utils/deviceUtils.ts +76 -0
- package/src/utils/errorUtils.ts +63 -0
- package/src/utils/fileUtils.ts +257 -0
- package/src/utils/githubUtils.ts +6 -0
- package/src/utils/jsonUtils.ts +30 -0
- package/src/utils/lintUtils.ts +190 -0
- package/src/utils/logUtils.ts +9 -0
- package/src/utils/pathUtils.ts +12 -0
- package/src/utils/stringUtils.spec.ts +19 -0
- package/src/utils/stringUtils.ts +15 -0
- package/src/utils/tempDir.ts +24 -0
- package/src/utils/zipUtils.ts +14 -0
- package/test/ValdiSmokeTest.ts +278 -0
- package/test/helpers/AsyncHelpers.ts +113 -0
- package/test/helpers/CommandHelpers.ts +37 -0
- package/test/helpers/ProjectHelpers.ts +153 -0
- package/test/helpers/StreamHelpers.ts +37 -0
- package/test/helpers/TypeScriptClient.ts +217 -0
- package/tsconfig.dist.json +8 -0
- package/tsconfig.json +42 -0
|
@@ -0,0 +1,892 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handler = exports.builder = exports.describe = exports.command = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
+
const os = tslib_1.__importStar(require("os"));
|
|
7
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
const constants_1 = require("../core/constants");
|
|
9
|
+
const versions_1 = require("../setup/versions");
|
|
10
|
+
const BazelClient_1 = require("../utils/BazelClient");
|
|
11
|
+
const cliUtils_1 = require("../utils/cliUtils");
|
|
12
|
+
const errorUtils_1 = require("../utils/errorUtils");
|
|
13
|
+
const logUtils_1 = require("../utils/logUtils");
|
|
14
|
+
const DISCORD_SUPPORT_URL = 'https://discord.gg/uJyNEeYX2U';
|
|
15
|
+
class ValdiDoctor {
|
|
16
|
+
results = [];
|
|
17
|
+
verbose;
|
|
18
|
+
autoFix;
|
|
19
|
+
jsonOutput;
|
|
20
|
+
frameworkMode;
|
|
21
|
+
projectMode;
|
|
22
|
+
constructor(verbose, autoFix, jsonOutput, frameworkMode, projectMode) {
|
|
23
|
+
this.verbose = verbose;
|
|
24
|
+
this.autoFix = autoFix;
|
|
25
|
+
this.jsonOutput = jsonOutput;
|
|
26
|
+
this.frameworkMode = frameworkMode;
|
|
27
|
+
this.projectMode = projectMode;
|
|
28
|
+
}
|
|
29
|
+
async runDiagnostics() {
|
|
30
|
+
if (!this.jsonOutput) {
|
|
31
|
+
let mode = 'app development';
|
|
32
|
+
if (this.frameworkMode)
|
|
33
|
+
mode = 'framework development';
|
|
34
|
+
if (this.projectMode)
|
|
35
|
+
mode += ' + project';
|
|
36
|
+
console.log((0, logUtils_1.wrapInColor)(`Running Valdi environment diagnostics (${mode} mode)...`, constants_1.ANSI_COLORS.BLUE_COLOR));
|
|
37
|
+
console.log();
|
|
38
|
+
}
|
|
39
|
+
await this.checkNodeVersion();
|
|
40
|
+
await this.checkBazelInstallation();
|
|
41
|
+
if (this.projectMode) {
|
|
42
|
+
this.checkWorkspaceStructure();
|
|
43
|
+
}
|
|
44
|
+
await this.checkEssentialPlatformTools();
|
|
45
|
+
await this.checkJavaInstallation();
|
|
46
|
+
this.checkAndroidSDKBasics();
|
|
47
|
+
await this.checkCoreDependencies();
|
|
48
|
+
if (this.frameworkMode) {
|
|
49
|
+
await this.checkFrameworkDependencies();
|
|
50
|
+
this.checkAdvancedAndroidSDK();
|
|
51
|
+
this.checkEnvironmentVariables();
|
|
52
|
+
}
|
|
53
|
+
return this.results.some(r => r.status === 'fail') ? 'fail' : 'pass';
|
|
54
|
+
}
|
|
55
|
+
printResults() {
|
|
56
|
+
if (this.jsonOutput) {
|
|
57
|
+
this.printJsonResults();
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.printFormattedResults();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
addResult(result) {
|
|
64
|
+
this.results.push(result);
|
|
65
|
+
}
|
|
66
|
+
groupResultsByCategory() {
|
|
67
|
+
const groups = new Map();
|
|
68
|
+
for (const result of this.results) {
|
|
69
|
+
const category = result.category || result.name;
|
|
70
|
+
if (!groups.has(category)) {
|
|
71
|
+
groups.set(category, []);
|
|
72
|
+
}
|
|
73
|
+
const categoryGroup = groups.get(category);
|
|
74
|
+
if (categoryGroup) {
|
|
75
|
+
categoryGroup.push(result);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const groupedResults = [];
|
|
79
|
+
for (const [category, checks] of groups.entries()) {
|
|
80
|
+
let overallStatus = 'pass';
|
|
81
|
+
for (const check of checks) {
|
|
82
|
+
if (check.status === 'fail') {
|
|
83
|
+
overallStatus = 'fail';
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
else if (check.status === 'warn' && overallStatus === 'pass') {
|
|
87
|
+
overallStatus = 'warn';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const warnCount = checks.filter(c => c.status === 'warn').length;
|
|
91
|
+
const failCount = checks.filter(c => c.status === 'fail').length;
|
|
92
|
+
let message;
|
|
93
|
+
if (overallStatus === 'pass') {
|
|
94
|
+
const firstCheck = checks[0];
|
|
95
|
+
message = checks.length === 1 && firstCheck ? firstCheck.message : `All ${checks.length} checks passed`;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
const issues = failCount + warnCount;
|
|
99
|
+
message = `${issues} issue${issues > 1 ? 's' : ''} found`;
|
|
100
|
+
}
|
|
101
|
+
groupedResults.push({
|
|
102
|
+
category,
|
|
103
|
+
status: overallStatus,
|
|
104
|
+
message,
|
|
105
|
+
checks,
|
|
106
|
+
issues: checks.filter(c => c.status !== 'pass'),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return groupedResults;
|
|
110
|
+
}
|
|
111
|
+
async attemptAutoFix(tool, command) {
|
|
112
|
+
if (!this.autoFix) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
console.log((0, logUtils_1.wrapInColor)(`Attempting to fix ${tool}...`, constants_1.ANSI_COLORS.YELLOW_COLOR));
|
|
117
|
+
const { returnCode } = await (0, cliUtils_1.runCliCommand)(command);
|
|
118
|
+
if (returnCode === 0) {
|
|
119
|
+
console.log((0, logUtils_1.wrapInColor)(`✓ Successfully fixed ${tool}`, constants_1.ANSI_COLORS.GREEN_COLOR));
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
console.log((0, logUtils_1.wrapInColor)(`✗ Failed to fix ${tool}`, constants_1.ANSI_COLORS.RED_COLOR));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
console.log((0, logUtils_1.wrapInColor)(`✗ Failed to fix ${tool}: ${error instanceof Error ? error.message : 'Unknown error'}`, constants_1.ANSI_COLORS.RED_COLOR));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async checkNodeVersion() {
|
|
130
|
+
try {
|
|
131
|
+
const { stdout } = await (0, cliUtils_1.runCliCommand)('node --version');
|
|
132
|
+
const version = stdout.trim();
|
|
133
|
+
const versionParts = version.replace('v', '').split('.');
|
|
134
|
+
const majorVersionStr = versionParts[0];
|
|
135
|
+
if (!majorVersionStr) {
|
|
136
|
+
throw new Error('Invalid version format');
|
|
137
|
+
}
|
|
138
|
+
const majorVersion = Number.parseInt(majorVersionStr, 10);
|
|
139
|
+
if (majorVersion >= 18) {
|
|
140
|
+
this.addResult({
|
|
141
|
+
name: 'Node.js version',
|
|
142
|
+
status: 'pass',
|
|
143
|
+
message: `Node.js ${version} is installed`,
|
|
144
|
+
category: 'Node.js installation',
|
|
145
|
+
});
|
|
146
|
+
if (this.autoFix && majorVersion < 20) {
|
|
147
|
+
await this.attemptAutoFix('node', 'nvm install 20 && nvm use 20');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
this.addResult({
|
|
152
|
+
name: 'Node.js version',
|
|
153
|
+
status: 'fail',
|
|
154
|
+
message: `Node.js ${version} is outdated. Valdi requires Node.js 18 or higher`,
|
|
155
|
+
fixable: true,
|
|
156
|
+
fixCommand: 'nvm install 18 && nvm use 18',
|
|
157
|
+
category: 'Node.js installation',
|
|
158
|
+
});
|
|
159
|
+
if (this.autoFix) {
|
|
160
|
+
await this.attemptAutoFix('node', 'nvm install 18 && nvm use 18');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
this.addResult({
|
|
166
|
+
name: 'Node.js version',
|
|
167
|
+
status: 'fail',
|
|
168
|
+
message: 'Node.js is not installed or not in PATH',
|
|
169
|
+
fixable: true,
|
|
170
|
+
fixCommand: 'Install Node.js from https://nodejs.org or use nvm',
|
|
171
|
+
category: 'Node.js installation',
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
async checkBazelInstallation() {
|
|
176
|
+
try {
|
|
177
|
+
const bazel = new BazelClient_1.BazelClient();
|
|
178
|
+
const [returnCode, versionInfo, errorInfo] = await bazel.getVersion();
|
|
179
|
+
if (returnCode === 0 && versionInfo) {
|
|
180
|
+
const versionLine = versionInfo.split('\n')[0] || 'Unknown version';
|
|
181
|
+
const versionMatch = versionLine.match(/(\d+\.\d+\.\d+)/);
|
|
182
|
+
const installedVersion = versionMatch?.[1];
|
|
183
|
+
const bazelVersionFile = path_1.default.join(process.cwd(), '.bazelversion');
|
|
184
|
+
let expectedVersion;
|
|
185
|
+
try {
|
|
186
|
+
if (fs.existsSync(bazelVersionFile)) {
|
|
187
|
+
expectedVersion = fs.readFileSync(bazelVersionFile, 'utf8').trim();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
}
|
|
192
|
+
if (expectedVersion && installedVersion && installedVersion !== expectedVersion) {
|
|
193
|
+
this.addResult({
|
|
194
|
+
name: 'Bazel version',
|
|
195
|
+
status: 'warn',
|
|
196
|
+
message: `Bazel version mismatch: installed ${installedVersion}, expected ${expectedVersion}`,
|
|
197
|
+
details: 'Version mismatch may cause build issues. Consider updating Bazel.',
|
|
198
|
+
fixable: true,
|
|
199
|
+
fixCommand: `Install Bazel ${expectedVersion} or run a trial bazel command to verify compatibility`,
|
|
200
|
+
category: 'Bazel installation',
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
this.addResult({
|
|
205
|
+
name: 'Bazel installation',
|
|
206
|
+
status: 'pass',
|
|
207
|
+
message: `Bazel is installed: ${versionLine}${expectedVersion ? ` (matches expected ${expectedVersion})` : ''}`,
|
|
208
|
+
category: 'Bazel installation',
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
this.addResult({
|
|
214
|
+
name: 'Bazel installation',
|
|
215
|
+
status: 'fail',
|
|
216
|
+
message: 'Bazel is installed but not working correctly',
|
|
217
|
+
details: errorInfo || versionInfo || 'Unknown error',
|
|
218
|
+
category: 'Bazel installation',
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
this.addResult({
|
|
224
|
+
name: 'Bazel installation',
|
|
225
|
+
status: 'fail',
|
|
226
|
+
message: 'Bazel is not installed or not in PATH',
|
|
227
|
+
fixable: true,
|
|
228
|
+
fixCommand: 'Install Bazel from https://bazel.build/install',
|
|
229
|
+
category: 'Bazel installation',
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
checkWorkspaceStructure() {
|
|
234
|
+
const workspaceFile = path_1.default.join(process.cwd(), 'WORKSPACE');
|
|
235
|
+
const bazelrcFile = path_1.default.join(process.cwd(), '.bazelrc');
|
|
236
|
+
if (fs.existsSync(workspaceFile)) {
|
|
237
|
+
this.addResult({
|
|
238
|
+
name: 'Valdi workspace',
|
|
239
|
+
status: 'pass',
|
|
240
|
+
message: 'Valid Valdi workspace detected',
|
|
241
|
+
category: 'Workspace configuration',
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
this.addResult({
|
|
246
|
+
name: 'Valdi workspace',
|
|
247
|
+
status: 'fail',
|
|
248
|
+
message: 'Not in a Valdi workspace directory',
|
|
249
|
+
details: 'WORKSPACE file is required for all Valdi applications. Run `valdi bootstrap` to create a new project or navigate to an existing Valdi project root.',
|
|
250
|
+
fixable: true,
|
|
251
|
+
fixCommand: 'valdi bootstrap',
|
|
252
|
+
category: 'Workspace configuration',
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
if (fs.existsSync(bazelrcFile)) {
|
|
256
|
+
this.addResult({
|
|
257
|
+
name: 'Bazel configuration',
|
|
258
|
+
status: 'pass',
|
|
259
|
+
message: '.bazelrc file found',
|
|
260
|
+
category: 'Workspace configuration',
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
this.addResult({
|
|
265
|
+
name: 'Bazel configuration',
|
|
266
|
+
status: 'warn',
|
|
267
|
+
message: '.bazelrc file not found',
|
|
268
|
+
details: 'A .bazelrc file provides build optimization and consistency. Consider creating one or use `valdi bootstrap` for new projects.',
|
|
269
|
+
fixable: true,
|
|
270
|
+
fixCommand: 'Create .bazelrc file with Valdi-specific build configurations',
|
|
271
|
+
category: 'Workspace configuration',
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
async checkEssentialPlatformTools() {
|
|
276
|
+
const androidHome = process.env['ANDROID_HOME'] || process.env['ANDROID_SDK_ROOT'];
|
|
277
|
+
if (androidHome && fs.existsSync(androidHome)) {
|
|
278
|
+
this.addResult({
|
|
279
|
+
name: 'Android SDK',
|
|
280
|
+
status: 'pass',
|
|
281
|
+
message: `Android SDK found at ${androidHome}`,
|
|
282
|
+
category: 'Android installation',
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
this.addResult({
|
|
287
|
+
name: 'Android SDK',
|
|
288
|
+
status: 'warn',
|
|
289
|
+
message: 'Android SDK not found',
|
|
290
|
+
details: 'Required for Android app development. Set ANDROID_HOME environment variable.',
|
|
291
|
+
fixable: true,
|
|
292
|
+
fixCommand: 'Install Android Studio and set ANDROID_HOME',
|
|
293
|
+
category: 'Android installation',
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
if (os.platform() === 'darwin') {
|
|
297
|
+
if ((0, cliUtils_1.checkCommandExists)('xcode-select')) {
|
|
298
|
+
try {
|
|
299
|
+
const { stdout } = await (0, cliUtils_1.runCliCommand)('xcode-select -p');
|
|
300
|
+
this.addResult({
|
|
301
|
+
name: 'Xcode',
|
|
302
|
+
status: 'pass',
|
|
303
|
+
message: `Xcode found at ${stdout.trim()}`,
|
|
304
|
+
category: 'iOS development',
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
this.addResult({
|
|
309
|
+
name: 'Xcode',
|
|
310
|
+
status: 'warn',
|
|
311
|
+
message: 'Xcode not properly configured',
|
|
312
|
+
fixable: true,
|
|
313
|
+
fixCommand: 'xcode-select --install',
|
|
314
|
+
category: 'iOS development',
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
this.addResult({
|
|
320
|
+
name: 'Xcode',
|
|
321
|
+
status: 'warn',
|
|
322
|
+
message: 'Xcode command line tools not installed',
|
|
323
|
+
details: 'Required for iOS app development',
|
|
324
|
+
fixable: true,
|
|
325
|
+
fixCommand: 'Install Xcode from App Store and run: xcode-select --install',
|
|
326
|
+
category: 'iOS development',
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
async checkJavaInstallation() {
|
|
332
|
+
if ((0, cliUtils_1.checkCommandExists)('java')) {
|
|
333
|
+
try {
|
|
334
|
+
const { stdout, stderr } = await (0, cliUtils_1.runCliCommand)('java -version');
|
|
335
|
+
const versionInfo = stderr || stdout || '';
|
|
336
|
+
let versionMatch = versionInfo.match(/version "([^"]+)"/);
|
|
337
|
+
if (!versionMatch) {
|
|
338
|
+
versionMatch = versionInfo.match(/openjdk\s+(\d+\.\d+\.\d+)/i);
|
|
339
|
+
}
|
|
340
|
+
if (!versionMatch) {
|
|
341
|
+
versionMatch = versionInfo.match(/java\s+(\d+\.\d+\.\d+)/i);
|
|
342
|
+
}
|
|
343
|
+
const version = versionMatch?.[1] ?? 'Unknown version';
|
|
344
|
+
const majorVersionMatch = version.match(/^(\d+)/);
|
|
345
|
+
const majorVersion = majorVersionMatch?.[1] ? Number.parseInt(majorVersionMatch[1], 10) : 0;
|
|
346
|
+
if (majorVersion >= 17) {
|
|
347
|
+
this.addResult({
|
|
348
|
+
name: 'Java Runtime',
|
|
349
|
+
status: 'pass',
|
|
350
|
+
message: `Java is installed: ${version}`,
|
|
351
|
+
category: 'Java installation',
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
else if (majorVersion > 0) {
|
|
355
|
+
this.addResult({
|
|
356
|
+
name: 'Java Runtime',
|
|
357
|
+
status: 'warn',
|
|
358
|
+
message: `Java ${version} is outdated. Java 17+ is recommended`,
|
|
359
|
+
details: 'dev_setup now installs Java 17 for better compatibility',
|
|
360
|
+
fixable: true,
|
|
361
|
+
fixCommand: os.platform() === 'darwin' ? 'brew install openjdk@17' : 'sudo apt install openjdk-17-jdk',
|
|
362
|
+
category: 'Java installation',
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
this.addResult({
|
|
367
|
+
name: 'Java Runtime',
|
|
368
|
+
status: 'pass',
|
|
369
|
+
message: 'Java is installed',
|
|
370
|
+
details: `Version info: ${versionInfo.split('\n')[0] || 'Unable to parse version'}`,
|
|
371
|
+
category: 'Java installation',
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
catch {
|
|
376
|
+
this.addResult({
|
|
377
|
+
name: 'Java Runtime',
|
|
378
|
+
status: 'pass',
|
|
379
|
+
message: 'Java is installed',
|
|
380
|
+
category: 'Java installation',
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
this.addResult({
|
|
386
|
+
name: 'Java Runtime',
|
|
387
|
+
status: 'fail',
|
|
388
|
+
message: 'Java not found in PATH',
|
|
389
|
+
details: 'dev_setup installs Java JDK for Android development',
|
|
390
|
+
fixable: true,
|
|
391
|
+
fixCommand: os.platform() === 'darwin' ? 'brew install openjdk@17' : 'sudo apt install openjdk-17-jdk',
|
|
392
|
+
category: 'Java installation',
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
const javaHome = process.env['JAVA_HOME'];
|
|
396
|
+
if (javaHome && fs.existsSync(javaHome)) {
|
|
397
|
+
this.addResult({
|
|
398
|
+
name: 'JAVA_HOME',
|
|
399
|
+
status: 'pass',
|
|
400
|
+
message: `JAVA_HOME set to ${javaHome}`,
|
|
401
|
+
category: 'Java installation',
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
this.addResult({
|
|
406
|
+
name: 'JAVA_HOME',
|
|
407
|
+
status: 'warn',
|
|
408
|
+
message: 'JAVA_HOME not set or invalid',
|
|
409
|
+
details: 'dev_setup configures JAVA_HOME for Android development',
|
|
410
|
+
fixable: true,
|
|
411
|
+
fixCommand: os.platform() === 'darwin' ? 'export JAVA_HOME=`/usr/libexec/java_home -v 17`' : 'Set JAVA_HOME environment variable',
|
|
412
|
+
category: 'Java installation',
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
const pathEnv = process.env['PATH'] || '';
|
|
416
|
+
if (os.platform() === 'darwin') {
|
|
417
|
+
if (pathEnv.includes('/opt/homebrew/opt/openjdk@17/bin') || pathEnv.includes('/opt/homebrew/opt/openjdk@11/bin')) {
|
|
418
|
+
this.addResult({
|
|
419
|
+
name: 'Java PATH',
|
|
420
|
+
status: 'pass',
|
|
421
|
+
message: 'Java tools in PATH',
|
|
422
|
+
category: 'Java installation',
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
this.addResult({
|
|
427
|
+
name: 'Java PATH',
|
|
428
|
+
status: 'warn',
|
|
429
|
+
message: 'Java tools not in PATH',
|
|
430
|
+
details: 'dev_setup adds Java tools to PATH',
|
|
431
|
+
fixable: true,
|
|
432
|
+
fixCommand: 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"',
|
|
433
|
+
category: 'Java installation',
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
if (os.platform() === 'darwin') {
|
|
438
|
+
const jdk17Symlink = '/Library/Java/JavaVirtualMachines/openjdk-17.jdk';
|
|
439
|
+
const jdk11Symlink = '/Library/Java/JavaVirtualMachines/openjdk-11.jdk';
|
|
440
|
+
if (fs.existsSync(jdk17Symlink)) {
|
|
441
|
+
this.addResult({
|
|
442
|
+
name: 'Java JDK symlink',
|
|
443
|
+
status: 'pass',
|
|
444
|
+
message: 'OpenJDK 17 symlink configured',
|
|
445
|
+
category: 'Java installation',
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
else if (fs.existsSync(jdk11Symlink)) {
|
|
449
|
+
this.addResult({
|
|
450
|
+
name: 'Java JDK symlink',
|
|
451
|
+
status: 'warn',
|
|
452
|
+
message: 'OpenJDK 11 symlink found, but Java 17+ is recommended',
|
|
453
|
+
details: 'dev_setup now installs Java 17 for better compatibility',
|
|
454
|
+
fixable: true,
|
|
455
|
+
fixCommand: 'sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk',
|
|
456
|
+
category: 'Java installation',
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
this.addResult({
|
|
461
|
+
name: 'Java JDK symlink',
|
|
462
|
+
status: 'warn',
|
|
463
|
+
message: 'OpenJDK symlink not found',
|
|
464
|
+
details: 'dev_setup creates symlink for system-wide Java access',
|
|
465
|
+
fixable: true,
|
|
466
|
+
fixCommand: 'sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk',
|
|
467
|
+
category: 'Java installation',
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
checkAndroidSDKBasics() {
|
|
473
|
+
const androidHome = process.env['ANDROID_HOME'] || process.env['ANDROID_SDK_ROOT'];
|
|
474
|
+
if (!androidHome || !fs.existsSync(androidHome)) {
|
|
475
|
+
this.addResult({
|
|
476
|
+
name: 'Android SDK Components',
|
|
477
|
+
status: 'warn',
|
|
478
|
+
message: 'Cannot check Android SDK components - ANDROID_HOME not set',
|
|
479
|
+
details: 'Set ANDROID_HOME environment variable for Android development',
|
|
480
|
+
fixable: true,
|
|
481
|
+
fixCommand: 'Install Android Studio and set ANDROID_HOME',
|
|
482
|
+
category: 'Android installation',
|
|
483
|
+
});
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
const platformsDir = path_1.default.join(androidHome, 'platforms');
|
|
487
|
+
if (fs.existsSync(platformsDir)) {
|
|
488
|
+
const platforms = fs.readdirSync(platformsDir).filter(dir => dir.startsWith('android-'));
|
|
489
|
+
if (platforms.length > 0) {
|
|
490
|
+
this.addResult({
|
|
491
|
+
name: 'Android Platform',
|
|
492
|
+
status: 'pass',
|
|
493
|
+
message: `Android Platform installed (${platforms.length} version${platforms.length > 1 ? 's' : ''})`,
|
|
494
|
+
category: 'Android installation',
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
this.addResult({
|
|
499
|
+
name: 'Android Platform',
|
|
500
|
+
status: 'warn',
|
|
501
|
+
message: 'No Android Platform found',
|
|
502
|
+
details: 'Install an Android Platform via Android Studio SDK Manager',
|
|
503
|
+
fixable: true,
|
|
504
|
+
fixCommand: 'Open Android Studio > SDK Manager > Install an Android Platform',
|
|
505
|
+
category: 'Android installation',
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
this.addResult({
|
|
511
|
+
name: 'Android Platform',
|
|
512
|
+
status: 'warn',
|
|
513
|
+
message: 'Android platforms directory not found',
|
|
514
|
+
fixable: true,
|
|
515
|
+
fixCommand: 'Install Android Studio and configure SDK',
|
|
516
|
+
category: 'Android installation',
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
const buildToolsDir = path_1.default.join(androidHome, 'build-tools');
|
|
520
|
+
if (fs.existsSync(buildToolsDir)) {
|
|
521
|
+
const buildTools = fs.readdirSync(buildToolsDir);
|
|
522
|
+
if (buildTools.length > 0) {
|
|
523
|
+
this.addResult({
|
|
524
|
+
name: 'Android Build Tools',
|
|
525
|
+
status: 'pass',
|
|
526
|
+
message: `Android Build Tools installed (${buildTools.length} version${buildTools.length > 1 ? 's' : ''})`,
|
|
527
|
+
category: 'Android installation',
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
this.addResult({
|
|
532
|
+
name: 'Android Build Tools',
|
|
533
|
+
status: 'warn',
|
|
534
|
+
message: 'No Android Build Tools found',
|
|
535
|
+
fixable: true,
|
|
536
|
+
fixCommand: 'Install Build Tools via Android Studio SDK Manager',
|
|
537
|
+
category: 'Android installation',
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
this.addResult({
|
|
543
|
+
name: 'Android Build Tools',
|
|
544
|
+
status: 'warn',
|
|
545
|
+
message: 'Build tools directory not found',
|
|
546
|
+
fixable: true,
|
|
547
|
+
fixCommand: 'Install Android Studio and configure SDK',
|
|
548
|
+
category: 'Android installation',
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
async checkCoreDependencies() {
|
|
553
|
+
const coreDeps = ['git', 'npm', 'watchman'];
|
|
554
|
+
for (const dep of coreDeps) {
|
|
555
|
+
await this.checkSingleDependency(dep, 'fail');
|
|
556
|
+
}
|
|
557
|
+
if (os.platform() === 'darwin') {
|
|
558
|
+
await this.checkSingleDependency('ios_webkit_debug_proxy', 'fail');
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
async checkFrameworkDependencies() {
|
|
562
|
+
const frameworkDeps = ['git-lfs'];
|
|
563
|
+
for (const dep of frameworkDeps) {
|
|
564
|
+
await this.checkSingleDependency(dep, 'warn');
|
|
565
|
+
}
|
|
566
|
+
if (os.platform() === 'darwin') {
|
|
567
|
+
const temurinPath = '/opt/homebrew/opt/temurin';
|
|
568
|
+
if (fs.existsSync(temurinPath)) {
|
|
569
|
+
this.addResult({
|
|
570
|
+
name: 'temurin package',
|
|
571
|
+
status: 'pass',
|
|
572
|
+
message: 'temurin installed via Homebrew',
|
|
573
|
+
category: 'Framework tools',
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
this.addResult({
|
|
578
|
+
name: 'temurin package',
|
|
579
|
+
status: 'warn',
|
|
580
|
+
message: 'temurin not found',
|
|
581
|
+
details: 'Alternative JDK for framework development',
|
|
582
|
+
fixable: true,
|
|
583
|
+
fixCommand: 'brew install temurin',
|
|
584
|
+
category: 'Framework tools',
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
checkAdvancedAndroidSDK() {
|
|
590
|
+
const androidHome = process.env['ANDROID_HOME'] || process.env['ANDROID_SDK_ROOT'];
|
|
591
|
+
if (!androidHome || !fs.existsSync(androidHome)) {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
const platformPath = path_1.default.join(androidHome, 'platforms', versions_1.ANDROID_PLATFORM_VERSION);
|
|
595
|
+
if (fs.existsSync(platformPath)) {
|
|
596
|
+
this.addResult({
|
|
597
|
+
name: `Android Platform ${versions_1.ANDROID_PLATFORM_VERSION}`,
|
|
598
|
+
status: 'pass',
|
|
599
|
+
message: `Android Platform ${versions_1.ANDROID_PLATFORM_VERSION} installed`,
|
|
600
|
+
category: 'Android installation',
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
else {
|
|
604
|
+
this.addResult({
|
|
605
|
+
name: `Android Platform ${versions_1.ANDROID_PLATFORM_VERSION}`,
|
|
606
|
+
status: 'warn',
|
|
607
|
+
message: `Android Platform ${versions_1.ANDROID_PLATFORM_VERSION} not found`,
|
|
608
|
+
details: 'Specific platform version for framework development',
|
|
609
|
+
fixable: true,
|
|
610
|
+
fixCommand: `sdkmanager --install 'platforms;${versions_1.ANDROID_PLATFORM_VERSION}'`,
|
|
611
|
+
category: 'Android installation',
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
const ndkPath = path_1.default.join(androidHome, 'ndk', versions_1.ANDROID_NDK_VERSION);
|
|
615
|
+
if (fs.existsSync(ndkPath)) {
|
|
616
|
+
this.addResult({
|
|
617
|
+
name: 'Android NDK',
|
|
618
|
+
status: 'pass',
|
|
619
|
+
message: `Android NDK ${versions_1.ANDROID_NDK_VERSION} installed`,
|
|
620
|
+
category: 'Android installation',
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
this.addResult({
|
|
625
|
+
name: 'Android NDK',
|
|
626
|
+
status: 'warn',
|
|
627
|
+
message: `Android NDK ${versions_1.ANDROID_NDK_VERSION} not found`,
|
|
628
|
+
details: 'Required for native development in framework',
|
|
629
|
+
fixable: true,
|
|
630
|
+
fixCommand: `sdkmanager --install 'ndk;${versions_1.ANDROID_NDK_VERSION}'`,
|
|
631
|
+
category: 'Android installation',
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
async checkSingleDependency(dep, failureLevel) {
|
|
636
|
+
let category;
|
|
637
|
+
if (['git', 'npm', 'watchman', 'ios_webkit_debug_proxy'].includes(dep)) {
|
|
638
|
+
category = 'Development tools';
|
|
639
|
+
}
|
|
640
|
+
else if (['git-lfs', 'temurin'].includes(dep)) {
|
|
641
|
+
category = 'Framework tools';
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
category = 'Development tools';
|
|
645
|
+
}
|
|
646
|
+
if ((0, cliUtils_1.checkCommandExists)(dep)) {
|
|
647
|
+
try {
|
|
648
|
+
const { stdout } = await (0, cliUtils_1.runCliCommand)(`${dep} --version`);
|
|
649
|
+
const versionLine = stdout.split('\n')[0] || 'Unknown version';
|
|
650
|
+
this.addResult({
|
|
651
|
+
name: `${dep} installation`,
|
|
652
|
+
status: 'pass',
|
|
653
|
+
message: `${dep} is installed: ${versionLine}`,
|
|
654
|
+
category,
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
catch {
|
|
658
|
+
this.addResult({
|
|
659
|
+
name: `${dep} installation`,
|
|
660
|
+
status: 'pass',
|
|
661
|
+
message: `${dep} is installed`,
|
|
662
|
+
category,
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
const fixCommand = this.getFixCommandForDependency(dep);
|
|
668
|
+
this.addResult({
|
|
669
|
+
name: `${dep} installation`,
|
|
670
|
+
status: failureLevel,
|
|
671
|
+
message: `${dep} is not installed or not in PATH`,
|
|
672
|
+
fixable: true,
|
|
673
|
+
fixCommand,
|
|
674
|
+
category,
|
|
675
|
+
});
|
|
676
|
+
if (this.autoFix && failureLevel === 'fail') {
|
|
677
|
+
await this.attemptAutoFix(dep, fixCommand);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
checkEnvironmentVariables() {
|
|
682
|
+
const androidHome = process.env['ANDROID_HOME'];
|
|
683
|
+
if (androidHome && fs.existsSync(androidHome)) {
|
|
684
|
+
this.addResult({
|
|
685
|
+
name: 'ANDROID_HOME',
|
|
686
|
+
status: 'pass',
|
|
687
|
+
message: `ANDROID_HOME set to ${androidHome}`,
|
|
688
|
+
category: 'Android installation',
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
this.addResult({
|
|
693
|
+
name: 'ANDROID_HOME',
|
|
694
|
+
status: 'fail',
|
|
695
|
+
message: 'ANDROID_HOME not set or invalid',
|
|
696
|
+
details: 'dev_setup configures ANDROID_HOME for Android development',
|
|
697
|
+
fixable: true,
|
|
698
|
+
fixCommand: 'valdi dev_setup',
|
|
699
|
+
category: 'Android installation',
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
const androidNdkHome = process.env['ANDROID_NDK_HOME'];
|
|
703
|
+
if (androidNdkHome && fs.existsSync(androidNdkHome)) {
|
|
704
|
+
this.addResult({
|
|
705
|
+
name: 'ANDROID_NDK_HOME',
|
|
706
|
+
status: 'pass',
|
|
707
|
+
message: `ANDROID_NDK_HOME set to ${androidNdkHome}`,
|
|
708
|
+
category: 'Android installation',
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
this.addResult({
|
|
713
|
+
name: 'ANDROID_NDK_HOME',
|
|
714
|
+
status: 'warn',
|
|
715
|
+
message: 'ANDROID_NDK_HOME not set or invalid',
|
|
716
|
+
details: 'dev_setup configures ANDROID_NDK_HOME for native development',
|
|
717
|
+
fixable: true,
|
|
718
|
+
fixCommand: 'valdi dev_setup',
|
|
719
|
+
category: 'Android installation',
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
const pathEnv = process.env['PATH'] || '';
|
|
723
|
+
if (os.platform() === 'linux') {
|
|
724
|
+
if (pathEnv.includes('/.valdi/bin')) {
|
|
725
|
+
this.addResult({
|
|
726
|
+
name: 'Bazelisk PATH',
|
|
727
|
+
status: 'pass',
|
|
728
|
+
message: 'Bazelisk directory in PATH',
|
|
729
|
+
category: 'Bazel installation',
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
else {
|
|
733
|
+
this.addResult({
|
|
734
|
+
name: 'Bazelisk PATH',
|
|
735
|
+
status: 'warn',
|
|
736
|
+
message: 'Bazelisk directory not in PATH',
|
|
737
|
+
details: 'dev_setup adds ~/.valdi/bin to PATH for Bazelisk',
|
|
738
|
+
fixable: true,
|
|
739
|
+
fixCommand: 'export PATH="$HOME/.valdi/bin:$PATH"',
|
|
740
|
+
category: 'Bazel installation',
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
getFixCommandForDependency(dep) {
|
|
746
|
+
switch (dep) {
|
|
747
|
+
case 'git': {
|
|
748
|
+
return os.platform() === 'darwin' ? 'brew install git' : 'sudo apt-get install git';
|
|
749
|
+
}
|
|
750
|
+
case 'npm': {
|
|
751
|
+
return 'Install Node.js from https://nodejs.org (includes npm)';
|
|
752
|
+
}
|
|
753
|
+
case 'watchman': {
|
|
754
|
+
return os.platform() === 'darwin' ? 'brew install watchman' : 'sudo apt-get install watchman';
|
|
755
|
+
}
|
|
756
|
+
case 'git-lfs': {
|
|
757
|
+
return os.platform() === 'darwin' ? 'brew install git-lfs' : 'sudo apt-get install git-lfs';
|
|
758
|
+
}
|
|
759
|
+
case 'bazelisk': {
|
|
760
|
+
return os.platform() === 'darwin' ? 'brew install bazelisk' : 'valdi dev_setup';
|
|
761
|
+
}
|
|
762
|
+
case 'ios_webkit_debug_proxy': {
|
|
763
|
+
return 'brew install ios-webkit-debug-proxy';
|
|
764
|
+
}
|
|
765
|
+
case 'adb': {
|
|
766
|
+
return 'sudo apt-get install adb';
|
|
767
|
+
}
|
|
768
|
+
default: {
|
|
769
|
+
return os.platform() === 'darwin' ? `brew install ${dep}` : `Install ${dep}`;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
printJsonResults() {
|
|
774
|
+
const passCount = this.results.filter(r => r.status === 'pass').length;
|
|
775
|
+
const warnCount = this.results.filter(r => r.status === 'warn').length;
|
|
776
|
+
const failCount = this.results.filter(r => r.status === 'fail').length;
|
|
777
|
+
const output = {
|
|
778
|
+
timestamp: new Date().toISOString(),
|
|
779
|
+
summary: {
|
|
780
|
+
passed: passCount,
|
|
781
|
+
warnings: warnCount,
|
|
782
|
+
failed: failCount,
|
|
783
|
+
total: this.results.length,
|
|
784
|
+
},
|
|
785
|
+
results: this.results,
|
|
786
|
+
};
|
|
787
|
+
console.log(JSON.stringify(output, null, 2));
|
|
788
|
+
}
|
|
789
|
+
printFormattedResults() {
|
|
790
|
+
console.log((0, logUtils_1.wrapInColor)('Valdi Doctor Report', constants_1.ANSI_COLORS.BLUE_COLOR));
|
|
791
|
+
console.log('='.repeat(50));
|
|
792
|
+
console.log();
|
|
793
|
+
const groupedResults = this.groupResultsByCategory();
|
|
794
|
+
let totalPassCount = 0;
|
|
795
|
+
let totalWarnCount = 0;
|
|
796
|
+
let totalFailCount = 0;
|
|
797
|
+
for (const group of groupedResults) {
|
|
798
|
+
const statusIcon = group.status === 'pass' ? '✓' : group.status === 'warn' ? '⚠' : '✗';
|
|
799
|
+
const statusColor = group.status === 'pass' ? constants_1.ANSI_COLORS.GREEN_COLOR :
|
|
800
|
+
group.status === 'warn' ? constants_1.ANSI_COLORS.YELLOW_COLOR : constants_1.ANSI_COLORS.RED_COLOR;
|
|
801
|
+
console.log(`${(0, logUtils_1.wrapInColor)(statusIcon, statusColor)} ${group.category}`);
|
|
802
|
+
if (group.issues.length > 0) {
|
|
803
|
+
for (const issue of group.issues) {
|
|
804
|
+
console.log(` • ${issue.message}`);
|
|
805
|
+
if (this.verbose && issue.details) {
|
|
806
|
+
console.log(` ${(0, logUtils_1.wrapInColor)('Details:', constants_1.ANSI_COLORS.GRAY_COLOR)} ${issue.details}`);
|
|
807
|
+
}
|
|
808
|
+
if (issue.fixable && issue.fixCommand) {
|
|
809
|
+
console.log(` ${(0, logUtils_1.wrapInColor)('Fix:', constants_1.ANSI_COLORS.BLUE_COLOR)} ${issue.fixCommand}`);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
console.log();
|
|
814
|
+
for (const check of group.checks) {
|
|
815
|
+
if (check.status === 'pass')
|
|
816
|
+
totalPassCount++;
|
|
817
|
+
else if (check.status === 'warn')
|
|
818
|
+
totalWarnCount++;
|
|
819
|
+
else
|
|
820
|
+
totalFailCount++;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
console.log('='.repeat(50));
|
|
824
|
+
console.log(`${(0, logUtils_1.wrapInColor)('Summary:', constants_1.ANSI_COLORS.BLUE_COLOR)} ${totalPassCount} passed, ${totalWarnCount} warnings, ${totalFailCount} failed`);
|
|
825
|
+
if (totalFailCount > 0) {
|
|
826
|
+
console.log();
|
|
827
|
+
console.log((0, logUtils_1.wrapInColor)('Some issues need to be resolved before Valdi can work properly.', constants_1.ANSI_COLORS.RED_COLOR));
|
|
828
|
+
console.log();
|
|
829
|
+
console.log((0, logUtils_1.wrapInColor)('Still having trouble? Come get help on Discord:', constants_1.ANSI_COLORS.BLUE_COLOR));
|
|
830
|
+
console.log((0, logUtils_1.wrapInColor)(DISCORD_SUPPORT_URL, constants_1.ANSI_COLORS.BLUE_COLOR));
|
|
831
|
+
console.log((0, logUtils_1.wrapInColor)('Please paste the entire output of this command when asking for help.', constants_1.ANSI_COLORS.YELLOW_COLOR));
|
|
832
|
+
}
|
|
833
|
+
else if (totalWarnCount > 0) {
|
|
834
|
+
console.log();
|
|
835
|
+
console.log((0, logUtils_1.wrapInColor)('Your environment is mostly ready, but some optional tools are missing.', constants_1.ANSI_COLORS.YELLOW_COLOR));
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
console.log();
|
|
839
|
+
console.log((0, logUtils_1.wrapInColor)('Your Valdi development environment is ready! 🎉', constants_1.ANSI_COLORS.GREEN_COLOR));
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
async function valdiDoctor(argv) {
|
|
844
|
+
const verbose = argv.getArgument('verbose');
|
|
845
|
+
const autoFix = argv.getArgument('fix');
|
|
846
|
+
const jsonOutput = argv.getArgument('json');
|
|
847
|
+
const frameworkMode = argv.getArgument('framework');
|
|
848
|
+
const projectMode = argv.getArgument('project');
|
|
849
|
+
const doctor = new ValdiDoctor(verbose, autoFix, jsonOutput, frameworkMode, projectMode);
|
|
850
|
+
const status = await doctor.runDiagnostics();
|
|
851
|
+
doctor.printResults();
|
|
852
|
+
if (status === 'fail') {
|
|
853
|
+
throw new Error('valdi doctor failed');
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
exports.command = 'doctor';
|
|
857
|
+
exports.describe = 'Check your Valdi development environment for common issues';
|
|
858
|
+
const builder = (yargs) => {
|
|
859
|
+
yargs
|
|
860
|
+
.option('verbose', {
|
|
861
|
+
describe: 'Show detailed diagnostic information',
|
|
862
|
+
type: 'boolean',
|
|
863
|
+
default: false,
|
|
864
|
+
alias: 'v',
|
|
865
|
+
})
|
|
866
|
+
.option('fix', {
|
|
867
|
+
describe: 'Attempt to automatically fix issues where possible',
|
|
868
|
+
type: 'boolean',
|
|
869
|
+
default: false,
|
|
870
|
+
alias: 'f',
|
|
871
|
+
})
|
|
872
|
+
.option('json', {
|
|
873
|
+
describe: 'Output results in JSON format',
|
|
874
|
+
type: 'boolean',
|
|
875
|
+
default: false,
|
|
876
|
+
alias: 'j',
|
|
877
|
+
})
|
|
878
|
+
.option('framework', {
|
|
879
|
+
describe: 'Include framework development checks (git-lfs, temurin, etc.)',
|
|
880
|
+
type: 'boolean',
|
|
881
|
+
default: false,
|
|
882
|
+
alias: 'F',
|
|
883
|
+
})
|
|
884
|
+
.option('project', {
|
|
885
|
+
describe: 'Include project-specific checks (workspace structure, etc.)',
|
|
886
|
+
type: 'boolean',
|
|
887
|
+
default: false,
|
|
888
|
+
alias: 'p',
|
|
889
|
+
});
|
|
890
|
+
};
|
|
891
|
+
exports.builder = builder;
|
|
892
|
+
exports.handler = (0, errorUtils_1.makeCommandHandler)(valdiDoctor);
|