spana-test 0.1.0 → 0.2.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.
Files changed (120) hide show
  1. package/.agents/skills/spana-testing/SKILL.md +4 -1
  2. package/README.md +277 -86
  3. package/dist/agent/index.d.ts +34 -5
  4. package/dist/agent/index.js +14 -10
  5. package/dist/{chunk-RK4Z6C7M.js → chunk-3YR4GUGE.js} +3 -2
  6. package/dist/chunk-3YR4GUGE.js.map +1 -0
  7. package/dist/{chunk-WIJYK22K.js → chunk-AEKDFFPJ.js} +2 -2
  8. package/dist/chunk-BF37W5EG.js +125 -0
  9. package/dist/chunk-BF37W5EG.js.map +1 -0
  10. package/dist/chunk-EXLUY7KT.js +21 -0
  11. package/dist/chunk-EXLUY7KT.js.map +1 -0
  12. package/dist/chunk-FNDOEMOL.js +62 -0
  13. package/dist/chunk-FNDOEMOL.js.map +1 -0
  14. package/dist/chunk-HWFDXIXR.js +183 -0
  15. package/dist/chunk-HWFDXIXR.js.map +1 -0
  16. package/dist/chunk-IJIASIX5.js +314 -0
  17. package/dist/chunk-IJIASIX5.js.map +1 -0
  18. package/dist/chunk-KJPHH2TW.js +168 -0
  19. package/dist/chunk-KJPHH2TW.js.map +1 -0
  20. package/dist/{chunk-RJ5VPHVX.js → chunk-L7MFJF46.js} +16 -6
  21. package/dist/chunk-L7MFJF46.js.map +1 -0
  22. package/dist/{chunk-5XO6S7AI.js → chunk-MRH7SK52.js} +4 -4
  23. package/dist/chunk-MRH7SK52.js.map +1 -0
  24. package/dist/{chunk-53MUJUJY.js → chunk-P7JQRLP4.js} +5 -4
  25. package/dist/{chunk-53MUJUJY.js.map → chunk-P7JQRLP4.js.map} +1 -1
  26. package/dist/chunk-S2XNAKSO.js +1087 -0
  27. package/dist/chunk-S2XNAKSO.js.map +1 -0
  28. package/dist/{chunk-VDWWIVM6.js → chunk-S4R4OR7T.js} +108 -53
  29. package/dist/chunk-S4R4OR7T.js.map +1 -0
  30. package/dist/{chunk-V62HFH6E.js → chunk-SFBRFB2N.js} +14 -6
  31. package/dist/chunk-SFBRFB2N.js.map +1 -0
  32. package/dist/{chunk-PWEOJKUF.js → chunk-VNYF5BHX.js} +28 -7
  33. package/dist/chunk-VNYF5BHX.js.map +1 -0
  34. package/dist/chunk-WBU34APM.js +38 -0
  35. package/dist/chunk-WBU34APM.js.map +1 -0
  36. package/dist/{chunk-CKJQX73M.js → chunk-WQ4GXUUE.js} +921 -352
  37. package/dist/chunk-WQ4GXUUE.js.map +1 -0
  38. package/dist/chunk-YBZCOQXJ.js +311 -0
  39. package/dist/chunk-YBZCOQXJ.js.map +1 -0
  40. package/dist/cli.js +316 -40
  41. package/dist/cli.js.map +1 -1
  42. package/dist/{compiler-G75RIIYS.js → compiler-74VGKZO6.js} +2 -2
  43. package/dist/{compiler-G75RIIYS.js.map → compiler-74VGKZO6.js.map} +1 -1
  44. package/dist/config-loader-BJJ3IJJ7.js +9 -0
  45. package/dist/{console-FV4RJPO4.js → console-XWKUTP3D.js} +39 -7
  46. package/dist/console-XWKUTP3D.js.map +1 -0
  47. package/dist/{config-Dg9O0rcQ.d.ts → coordinator-BbUjvvnX.d.ts} +165 -1
  48. package/dist/{discover-RWBKI5IB.js → discover-KZKXHZZA.js} +3 -3
  49. package/dist/doctor-command-T2UX5RV5.js +732 -0
  50. package/dist/doctor-command-T2UX5RV5.js.map +1 -0
  51. package/dist/{element-CGteXiXB.d.ts → element-DZ0HyJ3C.d.ts} +2 -0
  52. package/dist/{flow-D-_tlLpp.d.ts → flow-BUC9Mf8W.d.ts} +38 -9
  53. package/dist/gherkin/steps.d.ts +2 -2
  54. package/dist/{html-JP2HBIJQ.js → html-GE6Q4DCG.js} +23 -3
  55. package/dist/html-GE6Q4DCG.js.map +1 -0
  56. package/dist/index.d.ts +171 -3
  57. package/dist/index.js +6 -3
  58. package/dist/index.js.map +1 -1
  59. package/dist/{init-command-CELKL2CX.js → init-command-GVMRXIMY.js} +37 -21
  60. package/dist/init-command-GVMRXIMY.js.map +1 -0
  61. package/dist/init-flow-command-R76AXF4Z.js +34 -0
  62. package/dist/init-flow-command-R76AXF4Z.js.map +1 -0
  63. package/dist/{installer-R6NX7BYQ.js → installer-YZJ4DV3F.js} +4 -2
  64. package/dist/{ios-ZZU6DHH7.js → ios-ZW6XVNLG.js} +4 -2
  65. package/dist/json-KS67BZYU.js +39 -0
  66. package/dist/json-KS67BZYU.js.map +1 -0
  67. package/dist/{junit-UDY5JG22.js → junit-HLC62MK6.js} +2 -2
  68. package/dist/junit-HLC62MK6.js.map +1 -0
  69. package/dist/provider-A57C3MU6.js +12 -0
  70. package/dist/{redact-IDA3C4UH.js → redact-U72BUBBR.js} +2 -2
  71. package/dist/{redact-IDA3C4UH.js.map → redact-U72BUBBR.js.map} +1 -1
  72. package/dist/{runner-QEF6PJOE.js → runner-UXNHVVGG.js} +2 -2
  73. package/dist/{server-MMK7PZIH.js → server-W7OA3DDN.js} +49 -24
  74. package/dist/server-W7OA3DDN.js.map +1 -0
  75. package/dist/session-TMNOKYLG.js +17 -0
  76. package/dist/{studio-command-CDVPREMG.js → studio-command-6VHTHDUK.js} +2 -2
  77. package/dist/{test-command-SB5KYPQI.js → test-command-AHMOZLV4.js} +1280 -357
  78. package/dist/test-command-AHMOZLV4.js.map +1 -0
  79. package/dist/validator-35624P7S.js +20 -0
  80. package/package.json +1 -1
  81. package/studio-dist/assets/index-DC6DIXfl.js +188 -0
  82. package/studio-dist/assets/index-DDKsnBwD.css +1 -0
  83. package/studio-dist/index.html +2 -2
  84. package/dist/chunk-5XO6S7AI.js.map +0 -1
  85. package/dist/chunk-BZRLA4Z3.js +0 -82
  86. package/dist/chunk-BZRLA4Z3.js.map +0 -1
  87. package/dist/chunk-CKJQX73M.js.map +0 -1
  88. package/dist/chunk-PANFRTIU.js +0 -310
  89. package/dist/chunk-PANFRTIU.js.map +0 -1
  90. package/dist/chunk-PWEOJKUF.js.map +0 -1
  91. package/dist/chunk-RJ5VPHVX.js.map +0 -1
  92. package/dist/chunk-RK4Z6C7M.js.map +0 -1
  93. package/dist/chunk-U564GCO2.js +0 -259
  94. package/dist/chunk-U564GCO2.js.map +0 -1
  95. package/dist/chunk-V62HFH6E.js.map +0 -1
  96. package/dist/chunk-VDWWIVM6.js.map +0 -1
  97. package/dist/config-loader-JJ5RPP53.js +0 -9
  98. package/dist/console-FV4RJPO4.js.map +0 -1
  99. package/dist/html-JP2HBIJQ.js.map +0 -1
  100. package/dist/init-command-CELKL2CX.js.map +0 -1
  101. package/dist/json-JMRPUVY2.js +0 -20
  102. package/dist/json-JMRPUVY2.js.map +0 -1
  103. package/dist/junit-UDY5JG22.js.map +0 -1
  104. package/dist/provider-CUWPULGC.js +0 -10
  105. package/dist/server-MMK7PZIH.js.map +0 -1
  106. package/dist/session-FBJABNXL.js +0 -16
  107. package/dist/test-command-SB5KYPQI.js.map +0 -1
  108. package/dist/validator-CFQ55NUQ.js +0 -13
  109. package/studio-dist/assets/index-CPdpC9i-.css +0 -1
  110. package/studio-dist/assets/index-L1Wd0vop.js +0 -183
  111. /package/dist/{chunk-WIJYK22K.js.map → chunk-AEKDFFPJ.js.map} +0 -0
  112. /package/dist/{config-loader-JJ5RPP53.js.map → config-loader-BJJ3IJJ7.js.map} +0 -0
  113. /package/dist/{discover-RWBKI5IB.js.map → discover-KZKXHZZA.js.map} +0 -0
  114. /package/dist/{installer-R6NX7BYQ.js.map → installer-YZJ4DV3F.js.map} +0 -0
  115. /package/dist/{ios-ZZU6DHH7.js.map → ios-ZW6XVNLG.js.map} +0 -0
  116. /package/dist/{provider-CUWPULGC.js.map → provider-A57C3MU6.js.map} +0 -0
  117. /package/dist/{runner-QEF6PJOE.js.map → runner-UXNHVVGG.js.map} +0 -0
  118. /package/dist/{session-FBJABNXL.js.map → session-TMNOKYLG.js.map} +0 -0
  119. /package/dist/{studio-command-CDVPREMG.js.map → studio-command-6VHTHDUK.js.map} +0 -0
  120. /package/dist/{validator-CFQ55NUQ.js.map → validator-35624P7S.js.map} +0 -0
@@ -0,0 +1,732 @@
1
+ import {
2
+ resolveCapabilities
3
+ } from "./chunk-EXLUY7KT.js";
4
+ import {
5
+ loadConfig
6
+ } from "./chunk-P7JQRLP4.js";
7
+ import "./chunk-L7MFJF46.js";
8
+ import {
9
+ findUiAutomator2APK
10
+ } from "./chunk-BF37W5EG.js";
11
+ import {
12
+ configCommandError,
13
+ normalizeErrorMessage
14
+ } from "./chunk-WBU34APM.js";
15
+ import {
16
+ buildDocsUrl,
17
+ createMachineFailure,
18
+ createMachineSuccess,
19
+ printMachinePayload
20
+ } from "./chunk-FNDOEMOL.js";
21
+ import {
22
+ detectProvider,
23
+ hasConfig,
24
+ loadCustomProvider,
25
+ parseAppiumCredentials
26
+ } from "./chunk-VNYF5BHX.js";
27
+ import {
28
+ findADB,
29
+ listAVDs,
30
+ listAndroidDevices
31
+ } from "./chunk-GZK22EIE.js";
32
+ import {
33
+ hasIproxy,
34
+ listBootedSimulators,
35
+ listIOSPhysicalDevices,
36
+ listIOSSimulators
37
+ } from "./chunk-SFBRFB2N.js";
38
+ import {
39
+ findWDAProject
40
+ } from "./chunk-3YR4GUGE.js";
41
+ import "./chunk-DGUM43GV.js";
42
+
43
+ // src/cli/doctor-command.ts
44
+ import { existsSync } from "fs";
45
+ import { dirname } from "path";
46
+ var defaultDoctorDependencies = {
47
+ loadConfig,
48
+ findADB,
49
+ listAVDs,
50
+ listAndroidDevices,
51
+ listIOSSimulators,
52
+ listBootedSimulators,
53
+ listIOSPhysicalDevices,
54
+ hasIproxy,
55
+ findUiAutomator2APK,
56
+ findWDAProject,
57
+ resolveCapabilities,
58
+ detectProvider,
59
+ loadCustomProvider
60
+ };
61
+ function passCheck(id, category, summary, details) {
62
+ return { id, category, status: "pass", summary, details };
63
+ }
64
+ function warnCheck(id, category, summary, suggestedFix, docsUrl, details) {
65
+ return { id, category, status: "warn", summary, suggestedFix, docsUrl, details };
66
+ }
67
+ function failCheck(id, category, summary, suggestedFix, docsUrl, details) {
68
+ return { id, category, status: "fail", summary, suggestedFix, docsUrl, details };
69
+ }
70
+ function getAppConfig(config, platform) {
71
+ switch (platform) {
72
+ case "web":
73
+ return config.apps?.web;
74
+ case "android":
75
+ return config.apps?.android;
76
+ case "ios":
77
+ return config.apps?.ios;
78
+ }
79
+ }
80
+ function inferPlatforms(config) {
81
+ if (config.platforms && config.platforms.length > 0) {
82
+ return [...new Set(config.platforms)];
83
+ }
84
+ const configuredPlatforms = ["web", "android", "ios"].filter(
85
+ (platform) => Boolean(getAppConfig(config, platform))
86
+ );
87
+ return configuredPlatforms.length > 0 ? [...configuredPlatforms] : ["web"];
88
+ }
89
+ function summarizeChecks(checks) {
90
+ return checks.reduce(
91
+ (summary, check) => {
92
+ if (check.status === "pass") {
93
+ summary.passCount += 1;
94
+ } else if (check.status === "warn") {
95
+ summary.warningCount += 1;
96
+ } else {
97
+ summary.failCount += 1;
98
+ }
99
+ return summary;
100
+ },
101
+ { passCount: 0, warningCount: 0, failCount: 0 }
102
+ );
103
+ }
104
+ function describeCloudProvider(appiumUrl, deps) {
105
+ const provider = deps.detectProvider(appiumUrl);
106
+ return provider ? provider.name() : "custom";
107
+ }
108
+ function hasAppReference(app) {
109
+ return Boolean(app?.id || app?.path);
110
+ }
111
+ function hasCapability(caps, keys) {
112
+ return keys.some((key) => {
113
+ const value = caps[key];
114
+ return typeof value === "string" && value.length > 0;
115
+ });
116
+ }
117
+ function collectWebChecks(config) {
118
+ const checks = [];
119
+ const docsUrl = buildDocsUrl("/getting-started/configuration");
120
+ const appConfig = config.apps?.web;
121
+ const targetUrl = appConfig?.url ?? "http://localhost:3000";
122
+ try {
123
+ const url = new URL(targetUrl);
124
+ checks.push(passCheck("web-url", "web", `Web target URL resolved to ${url.href}`));
125
+ } catch {
126
+ checks.push(
127
+ failCheck(
128
+ "web-url",
129
+ "web",
130
+ `Web target URL is invalid: ${targetUrl}`,
131
+ "Set `apps.web.url` to a valid absolute URL.",
132
+ docsUrl
133
+ )
134
+ );
135
+ }
136
+ const storageState = config.execution?.web?.storageState;
137
+ if (storageState) {
138
+ checks.push(
139
+ existsSync(storageState) ? passCheck("web-storage-state", "web", `Web storage state file found at ${storageState}`) : failCheck(
140
+ "web-storage-state",
141
+ "web",
142
+ `Web storage state file is missing: ${storageState}`,
143
+ "Update `execution.web.storageState` or create the storage state file before running tests.",
144
+ docsUrl
145
+ )
146
+ );
147
+ }
148
+ return checks;
149
+ }
150
+ function collectAndroidChecks(config, deps) {
151
+ const checks = [];
152
+ const configDocsUrl = buildDocsUrl("/getting-started/configuration");
153
+ const deviceDocsUrl = buildDocsUrl("/guides/device-setup");
154
+ const driverDocsUrl = buildDocsUrl("/architecture/drivers");
155
+ const appConfig = config.apps?.android;
156
+ if (!appConfig?.packageName) {
157
+ checks.push(
158
+ failCheck(
159
+ "android-package-name",
160
+ "android",
161
+ "Android packageName is missing.",
162
+ "Set `apps.android.packageName` so Spana knows which installed app to launch.",
163
+ configDocsUrl
164
+ )
165
+ );
166
+ } else {
167
+ checks.push(passCheck("android-package-name", "android", `Android packageName set to ${appConfig.packageName}`));
168
+ }
169
+ if (appConfig?.appPath) {
170
+ checks.push(
171
+ existsSync(appConfig.appPath) ? passCheck("android-app-path", "android", `Android app bundle found at ${appConfig.appPath}`) : failCheck(
172
+ "android-app-path",
173
+ "android",
174
+ `Android app bundle is missing: ${appConfig.appPath}`,
175
+ "Update `apps.android.appPath` or place the APK/AAB at the configured path.",
176
+ deviceDocsUrl
177
+ )
178
+ );
179
+ } else {
180
+ checks.push(
181
+ warnCheck(
182
+ "android-app-path",
183
+ "android",
184
+ "No Android appPath configured; Spana will expect the app to already be installed.",
185
+ "Set `apps.android.appPath` if you want Spana to install the app automatically before local runs.",
186
+ deviceDocsUrl
187
+ )
188
+ );
189
+ }
190
+ const adbPath = deps.findADB();
191
+ if (!adbPath) {
192
+ checks.push(
193
+ failCheck(
194
+ "android-adb",
195
+ "android",
196
+ "Android Debug Bridge (adb) was not found.",
197
+ "Install Android platform-tools and ensure `adb` is available on PATH or under ANDROID_HOME/ANDROID_SDK_ROOT.",
198
+ deviceDocsUrl
199
+ )
200
+ );
201
+ } else {
202
+ checks.push(passCheck("android-adb", "android", `adb available at ${adbPath}`));
203
+ }
204
+ const readyDevices = deps.listAndroidDevices().filter((device) => device.state === "device");
205
+ if (readyDevices.length > 0) {
206
+ checks.push(
207
+ passCheck(
208
+ "android-device",
209
+ "android",
210
+ `Android device ready (${readyDevices[0].serial})`,
211
+ `${readyDevices.length} connected device(s) available.`
212
+ )
213
+ );
214
+ } else {
215
+ const avds = deps.listAVDs();
216
+ checks.push(
217
+ avds.length > 0 ? warnCheck(
218
+ "android-device",
219
+ "android",
220
+ `No connected Android device found; ${avds.length} emulator image(s) are available for auto-start.`,
221
+ "Start an emulator or connect a device if you want fully ready local Android runs before invoking `spana test`.",
222
+ deviceDocsUrl
223
+ ) : failCheck(
224
+ "android-device",
225
+ "android",
226
+ "No connected Android device or emulator is available.",
227
+ "Start an Android emulator or connect a device before running local Android flows.",
228
+ deviceDocsUrl
229
+ )
230
+ );
231
+ }
232
+ const uiAutomator2Apks = deps.findUiAutomator2APK();
233
+ checks.push(
234
+ uiAutomator2Apks ? passCheck(
235
+ "android-uiautomator2",
236
+ "android",
237
+ `UiAutomator2 artifacts found (${dirname(uiAutomator2Apks.serverApk)})`
238
+ ) : failCheck(
239
+ "android-uiautomator2",
240
+ "android",
241
+ "UiAutomator2 server artifacts were not found.",
242
+ "Install `appium-uiautomator2-server` or place the APKs in `drivers/android/`.",
243
+ driverDocsUrl
244
+ )
245
+ );
246
+ return checks;
247
+ }
248
+ function collectIOSChecks(config, deps) {
249
+ const checks = [];
250
+ const configDocsUrl = buildDocsUrl("/getting-started/configuration");
251
+ const deviceDocsUrl = buildDocsUrl("/guides/device-setup");
252
+ const driverDocsUrl = buildDocsUrl("/architecture/drivers");
253
+ const appConfig = config.apps?.ios;
254
+ if (!appConfig?.bundleId) {
255
+ checks.push(
256
+ failCheck(
257
+ "ios-bundle-id",
258
+ "ios",
259
+ "iOS bundleId is missing.",
260
+ "Set `apps.ios.bundleId` so Spana knows which installed app to launch.",
261
+ configDocsUrl
262
+ )
263
+ );
264
+ } else {
265
+ checks.push(passCheck("ios-bundle-id", "ios", `iOS bundleId set to ${appConfig.bundleId}`));
266
+ }
267
+ if (appConfig?.appPath) {
268
+ checks.push(
269
+ existsSync(appConfig.appPath) ? passCheck("ios-app-path", "ios", `iOS app bundle found at ${appConfig.appPath}`) : failCheck(
270
+ "ios-app-path",
271
+ "ios",
272
+ `iOS app bundle is missing: ${appConfig.appPath}`,
273
+ "Update `apps.ios.appPath` or place the .app/.ipa at the configured path.",
274
+ deviceDocsUrl
275
+ )
276
+ );
277
+ } else {
278
+ checks.push(
279
+ warnCheck(
280
+ "ios-app-path",
281
+ "ios",
282
+ "No iOS appPath configured; Spana will expect the app to already be installed.",
283
+ "Set `apps.ios.appPath` if you want Spana to install the app automatically before local runs.",
284
+ deviceDocsUrl
285
+ )
286
+ );
287
+ }
288
+ const simulators = deps.listIOSSimulators().filter((simulator) => simulator.isAvailable);
289
+ const bootedSimulators = deps.listBootedSimulators().filter((simulator) => simulator.isAvailable);
290
+ const physicalDevices = deps.listIOSPhysicalDevices();
291
+ if (simulators.length === 0 && physicalDevices.length === 0) {
292
+ checks.push(
293
+ failCheck(
294
+ "ios-target",
295
+ "ios",
296
+ "No iOS simulators or physical devices are available.",
297
+ "Boot a simulator or connect a physical iOS device before running local iOS flows.",
298
+ deviceDocsUrl
299
+ )
300
+ );
301
+ } else {
302
+ checks.push(
303
+ passCheck(
304
+ "ios-target",
305
+ "ios",
306
+ `iOS target availability looks healthy (${simulators.length} simulator(s), ${physicalDevices.length} physical device(s)).`,
307
+ `${bootedSimulators.length} simulator(s) already booted.`
308
+ )
309
+ );
310
+ }
311
+ const requiresWDAProject = simulators.length > 0 || Boolean(appConfig?.signing?.teamId);
312
+ if (requiresWDAProject) {
313
+ const wdaProject = deps.findWDAProject();
314
+ checks.push(
315
+ wdaProject ? passCheck("ios-wda", "ios", `WebDriverAgent project found at ${wdaProject}`) : failCheck(
316
+ "ios-wda",
317
+ "ios",
318
+ "WebDriverAgent project was not found.",
319
+ "Install `appium-webdriveragent` or place WDA under `drivers/ios/WebDriverAgent/`.",
320
+ driverDocsUrl
321
+ )
322
+ );
323
+ }
324
+ if (physicalDevices.length > 0) {
325
+ if (appConfig?.signing?.teamId) {
326
+ checks.push(
327
+ passCheck(
328
+ "ios-signing",
329
+ "ios",
330
+ `iOS physical-device signing configured for team ${appConfig.signing.teamId}`
331
+ )
332
+ );
333
+ } else if (deps.hasIproxy()) {
334
+ checks.push(
335
+ warnCheck(
336
+ "ios-signing",
337
+ "ios",
338
+ "No iOS signing.teamId configured; physical-device runs assume WebDriverAgent is already installed on the device.",
339
+ "Add `apps.ios.signing.teamId` if Spana should build and install WebDriverAgent for physical-device runs.",
340
+ deviceDocsUrl,
341
+ "iproxy is available for tunnelling to a preinstalled WebDriverAgent instance."
342
+ )
343
+ );
344
+ } else {
345
+ const noSimulatorFallback = simulators.length === 0;
346
+ checks.push(
347
+ noSimulatorFallback ? failCheck(
348
+ "ios-signing",
349
+ "ios",
350
+ "Physical iOS devices are connected, but neither signing.teamId nor iproxy is available.",
351
+ "Install `iproxy` or configure `apps.ios.signing.teamId` so Spana can connect to WebDriverAgent.",
352
+ deviceDocsUrl
353
+ ) : warnCheck(
354
+ "ios-signing",
355
+ "ios",
356
+ "Physical iOS devices are connected, but iproxy is missing and signing.teamId is not configured.",
357
+ "Install `iproxy` or configure `apps.ios.signing.teamId` if you want physical-device runs to work reliably.",
358
+ deviceDocsUrl
359
+ )
360
+ );
361
+ }
362
+ }
363
+ return checks;
364
+ }
365
+ function collectAppiumBinaryChecks(config, checks) {
366
+ const cloudDocsUrl = buildDocsUrl("/guides/cloud-providers");
367
+ const browserStackLocalBinary = config.browserstack?.local?.binary;
368
+ if (config.browserstack?.local?.enabled) {
369
+ checks.push(
370
+ browserStackLocalBinary ? existsSync(browserStackLocalBinary) ? passCheck(
371
+ "appium-browserstack-local-binary",
372
+ "appium",
373
+ `BrowserStackLocal binary found at ${browserStackLocalBinary}`
374
+ ) : failCheck(
375
+ "appium-browserstack-local-binary",
376
+ "appium",
377
+ `BrowserStackLocal binary is missing: ${browserStackLocalBinary}`,
378
+ "Update `execution.appium.browserstack.local.binary` or remove it so the binary can be resolved from PATH.",
379
+ cloudDocsUrl
380
+ ) : warnCheck(
381
+ "appium-browserstack-local-binary",
382
+ "appium",
383
+ "BrowserStack Local is enabled without an explicit binary path.",
384
+ "Ensure `BrowserStackLocal` is installed on PATH before running Appium cloud tests.",
385
+ cloudDocsUrl
386
+ )
387
+ );
388
+ }
389
+ const sauceConnectBinary = config.saucelabs?.connect?.binary;
390
+ if (config.saucelabs?.connect?.enabled) {
391
+ checks.push(
392
+ sauceConnectBinary ? existsSync(sauceConnectBinary) ? passCheck(
393
+ "appium-sauce-connect-binary",
394
+ "appium",
395
+ `Sauce Connect binary found at ${sauceConnectBinary}`
396
+ ) : failCheck(
397
+ "appium-sauce-connect-binary",
398
+ "appium",
399
+ `Sauce Connect binary is missing: ${sauceConnectBinary}`,
400
+ "Update `execution.appium.saucelabs.connect.binary` or remove it so the binary can be resolved from PATH.",
401
+ cloudDocsUrl
402
+ ) : warnCheck(
403
+ "appium-sauce-connect-binary",
404
+ "appium",
405
+ "Sauce Connect is enabled without an explicit binary path.",
406
+ "Ensure `sc` is installed on PATH before running Appium cloud tests.",
407
+ cloudDocsUrl
408
+ )
409
+ );
410
+ }
411
+ }
412
+ function collectManagedAppChecks(config, appiumConfig, caps, platforms) {
413
+ const checks = [];
414
+ const cloudDocsUrl = buildDocsUrl("/guides/cloud-providers");
415
+ if (platforms.includes("android")) {
416
+ const hasAndroidTarget = hasCapability(caps, ["appium:app", "appium:appPackage"]) || hasAppReference(appiumConfig.browserstack?.app) || hasAppReference(appiumConfig.saucelabs?.app) || Boolean(config.apps?.android?.appPath);
417
+ checks.push(
418
+ hasAndroidTarget ? passCheck("appium-android-target", "appium", "Appium Android app target is configured.") : warnCheck(
419
+ "appium-android-target",
420
+ "appium",
421
+ "Appium Android capabilities do not declare an app or package name.",
422
+ "Set `appium:app`, `appium:appPackage`, or a managed cloud app reference before running Android Appium sessions.",
423
+ cloudDocsUrl
424
+ )
425
+ );
426
+ }
427
+ if (platforms.includes("ios")) {
428
+ const hasIOSTarget = hasCapability(caps, ["appium:app", "appium:bundleId"]) || hasAppReference(appiumConfig.browserstack?.app) || hasAppReference(appiumConfig.saucelabs?.app) || Boolean(config.apps?.ios?.appPath);
429
+ checks.push(
430
+ hasIOSTarget ? passCheck("appium-ios-target", "appium", "Appium iOS app target is configured.") : warnCheck(
431
+ "appium-ios-target",
432
+ "appium",
433
+ "Appium iOS capabilities do not declare an app or bundleId.",
434
+ "Set `appium:app`, `appium:bundleId`, or a managed cloud app reference before running iOS Appium sessions.",
435
+ cloudDocsUrl
436
+ )
437
+ );
438
+ }
439
+ return checks;
440
+ }
441
+ async function collectAppiumChecks(config, platforms, options, deps) {
442
+ const checks = [];
443
+ const appiumConfig = config.execution?.appium ?? {};
444
+ const configDocsUrl = buildDocsUrl("/getting-started/configuration");
445
+ const cloudDocsUrl = buildDocsUrl("/guides/cloud-providers");
446
+ const remoteDocsUrl = buildDocsUrl("/guides/remote-execution");
447
+ const appiumUrl = options.appiumUrl ?? appiumConfig.serverUrl;
448
+ if (!appiumUrl) {
449
+ checks.push(
450
+ failCheck(
451
+ "appium-url",
452
+ "appium",
453
+ "Appium execution mode is selected, but no Appium server URL is configured.",
454
+ "Set `execution.appium.serverUrl` or pass `--appium-url <url>`.",
455
+ remoteDocsUrl
456
+ )
457
+ );
458
+ return checks;
459
+ }
460
+ let parsedUrl;
461
+ try {
462
+ parsedUrl = new URL(appiumUrl);
463
+ checks.push(
464
+ passCheck(
465
+ "appium-url",
466
+ "appium",
467
+ `Appium server URL looks valid (${parsedUrl.host})`,
468
+ `Provider: ${describeCloudProvider(appiumUrl, deps)}`
469
+ )
470
+ );
471
+ } catch {
472
+ checks.push(
473
+ failCheck(
474
+ "appium-url",
475
+ "appium",
476
+ `Appium server URL is invalid: ${appiumUrl}`,
477
+ "Set `execution.appium.serverUrl` or `--appium-url` to a valid URL.",
478
+ remoteDocsUrl
479
+ )
480
+ );
481
+ }
482
+ if (appiumConfig.cloudProvider) {
483
+ try {
484
+ const provider2 = await deps.loadCustomProvider(appiumConfig.cloudProvider);
485
+ checks.push(
486
+ passCheck(
487
+ "appium-custom-provider",
488
+ "appium",
489
+ `Custom cloud provider module loaded (${provider2.name()})`,
490
+ appiumConfig.cloudProvider
491
+ )
492
+ );
493
+ } catch (error) {
494
+ checks.push(
495
+ failCheck(
496
+ "appium-custom-provider",
497
+ "appium",
498
+ `Failed to load custom cloud provider: ${normalizeErrorMessage(error)}`,
499
+ "Fix the module path/default export for `execution.appium.cloudProvider`.",
500
+ cloudDocsUrl
501
+ )
502
+ );
503
+ }
504
+ }
505
+ const provider = parsedUrl ? deps.detectProvider(appiumUrl) : null;
506
+ const hasBrowserStackConfig = hasConfig(appiumConfig.browserstack);
507
+ const hasSauceLabsConfig = hasConfig(appiumConfig.saucelabs);
508
+ if (!provider && (hasBrowserStackConfig || hasSauceLabsConfig)) {
509
+ checks.push(
510
+ failCheck(
511
+ "appium-provider-url",
512
+ "appium",
513
+ "Provider helper config is present, but the Appium URL is not a BrowserStack or Sauce Labs endpoint.",
514
+ "Use the matching provider URL or remove the provider-specific helper config.",
515
+ cloudDocsUrl
516
+ )
517
+ );
518
+ } else if (provider?.name() === "BrowserStack" && hasSauceLabsConfig) {
519
+ checks.push(
520
+ failCheck(
521
+ "appium-provider-url",
522
+ "appium",
523
+ "Sauce Labs helper config requires a Sauce Labs Appium URL.",
524
+ "Switch `execution.appium.serverUrl` to Sauce Labs or remove `execution.appium.saucelabs`.",
525
+ cloudDocsUrl
526
+ )
527
+ );
528
+ } else if (provider?.name() === "Sauce Labs" && hasBrowserStackConfig) {
529
+ checks.push(
530
+ failCheck(
531
+ "appium-provider-url",
532
+ "appium",
533
+ "BrowserStack helper config requires a BrowserStack Appium URL.",
534
+ "Switch `execution.appium.serverUrl` to BrowserStack or remove `execution.appium.browserstack`.",
535
+ cloudDocsUrl
536
+ )
537
+ );
538
+ } else if (provider) {
539
+ checks.push(passCheck("appium-provider-url", "appium", `Provider helper config matches ${provider.name()}.`));
540
+ }
541
+ if (parsedUrl && (hasBrowserStackConfig || hasSauceLabsConfig)) {
542
+ try {
543
+ const credentials = parseAppiumCredentials(
544
+ appiumUrl,
545
+ provider?.name() ?? "Cloud provider"
546
+ );
547
+ checks.push(
548
+ passCheck(
549
+ "appium-provider-credentials",
550
+ "appium",
551
+ `Provider credentials found in Appium URL for ${credentials.username}.`
552
+ )
553
+ );
554
+ } catch (error) {
555
+ checks.push(
556
+ failCheck(
557
+ "appium-provider-credentials",
558
+ "appium",
559
+ normalizeErrorMessage(error),
560
+ "Add encoded credentials to `execution.appium.serverUrl` before using provider helper features.",
561
+ cloudDocsUrl
562
+ )
563
+ );
564
+ }
565
+ }
566
+ collectAppiumBinaryChecks(appiumConfig, checks);
567
+ let caps;
568
+ try {
569
+ caps = await deps.resolveCapabilities(appiumConfig, {
570
+ capsPath: options.capsPath,
571
+ capsJson: options.capsJson
572
+ });
573
+ checks.push(
574
+ passCheck(
575
+ "appium-capabilities",
576
+ "appium",
577
+ `Resolved ${Object.keys(caps).length} Appium capability field(s).`
578
+ )
579
+ );
580
+ } catch (error) {
581
+ checks.push(
582
+ failCheck(
583
+ "appium-capabilities",
584
+ "appium",
585
+ `Failed to resolve Appium capabilities: ${normalizeErrorMessage(error)}`,
586
+ "Fix the capabilities JSON/file and rerun `spana doctor`.",
587
+ configDocsUrl
588
+ )
589
+ );
590
+ }
591
+ if (appiumConfig.browserstack?.app?.path) {
592
+ checks.push(
593
+ existsSync(appiumConfig.browserstack.app.path) ? passCheck(
594
+ "appium-browserstack-app-path",
595
+ "appium",
596
+ `BrowserStack managed app bundle found at ${appiumConfig.browserstack.app.path}`
597
+ ) : failCheck(
598
+ "appium-browserstack-app-path",
599
+ "appium",
600
+ `BrowserStack managed app bundle is missing: ${appiumConfig.browserstack.app.path}`,
601
+ "Update `execution.appium.browserstack.app.path` or use an existing BrowserStack app id instead.",
602
+ cloudDocsUrl
603
+ )
604
+ );
605
+ }
606
+ if (appiumConfig.saucelabs?.app?.path) {
607
+ checks.push(
608
+ existsSync(appiumConfig.saucelabs.app.path) ? passCheck(
609
+ "appium-saucelabs-app-path",
610
+ "appium",
611
+ `Sauce Labs managed app bundle found at ${appiumConfig.saucelabs.app.path}`
612
+ ) : failCheck(
613
+ "appium-saucelabs-app-path",
614
+ "appium",
615
+ `Sauce Labs managed app bundle is missing: ${appiumConfig.saucelabs.app.path}`,
616
+ "Update `execution.appium.saucelabs.app.path` or use an existing Sauce Labs app id instead.",
617
+ cloudDocsUrl
618
+ )
619
+ );
620
+ }
621
+ if (caps) {
622
+ checks.push(...collectManagedAppChecks(config, appiumConfig, caps, platforms));
623
+ }
624
+ return checks;
625
+ }
626
+ function printDoctorReport(summary, checks) {
627
+ const groupTitles = {
628
+ general: "General",
629
+ web: "Web",
630
+ android: "Android",
631
+ ios: "iOS",
632
+ appium: "Appium"
633
+ };
634
+ const symbols = {
635
+ pass: "\u2713",
636
+ warn: "!",
637
+ fail: "\u2717"
638
+ };
639
+ const orderedCategories = ["general", "web", "android", "ios", "appium"];
640
+ console.log(
641
+ `Doctor summary: ${summary.passCount} passed, ${summary.warningCount} warning(s), ${summary.failCount} failed`
642
+ );
643
+ for (const category of orderedCategories) {
644
+ const categoryChecks = checks.filter((check) => check.category === category);
645
+ if (categoryChecks.length === 0) {
646
+ continue;
647
+ }
648
+ console.log("");
649
+ console.log(groupTitles[category]);
650
+ for (const check of categoryChecks) {
651
+ console.log(` ${symbols[check.status]} ${check.summary}`);
652
+ if (check.details) {
653
+ console.log(` ${check.details}`);
654
+ }
655
+ if (check.suggestedFix) {
656
+ console.log(` Fix: ${check.suggestedFix}`);
657
+ }
658
+ }
659
+ }
660
+ }
661
+ async function runDoctorCommand(options, deps = defaultDoctorDependencies) {
662
+ let config;
663
+ let configPath;
664
+ try {
665
+ const loadedConfig = await deps.loadConfig({ configPath: options.configPath });
666
+ config = loadedConfig.config;
667
+ configPath = loadedConfig.configPath;
668
+ } catch (error) {
669
+ const message = normalizeErrorMessage(error);
670
+ if (options.json) {
671
+ printMachinePayload(createMachineFailure("doctor", configCommandError(message)), options.pretty);
672
+ } else {
673
+ console.log(message);
674
+ }
675
+ return false;
676
+ }
677
+ const platforms = options.platforms.length > 0 ? [...new Set(options.platforms)] : inferPlatforms(config);
678
+ const executionMode = options.driver ?? (options.appiumUrl ? "appium" : void 0) ?? config.execution?.mode ?? "local";
679
+ const checks = [
680
+ passCheck("config", "general", `Config loaded from ${configPath ?? "memory"}`),
681
+ passCheck("platforms", "general", `Doctor will check: ${platforms.join(", ")}`),
682
+ passCheck("execution-mode", "general", `Execution mode resolved to ${executionMode}`)
683
+ ];
684
+ if (platforms.includes("web")) {
685
+ checks.push(...collectWebChecks(config));
686
+ }
687
+ if (executionMode === "local") {
688
+ if (platforms.includes("android")) {
689
+ checks.push(...collectAndroidChecks(config, deps));
690
+ }
691
+ if (platforms.includes("ios")) {
692
+ checks.push(...collectIOSChecks(config, deps));
693
+ }
694
+ } else {
695
+ const mobilePlatforms = platforms.filter((platform) => platform !== "web");
696
+ if (mobilePlatforms.length === 0) {
697
+ checks.push(
698
+ warnCheck(
699
+ "appium-web-only",
700
+ "appium",
701
+ "Appium mode is selected, but only the web platform is targeted.",
702
+ "Remove `--driver appium` or add Android/iOS platforms if you intended to run remote mobile sessions.",
703
+ buildDocsUrl("/guides/remote-execution")
704
+ )
705
+ );
706
+ } else {
707
+ checks.push(...await collectAppiumChecks(config, mobilePlatforms, options, deps));
708
+ }
709
+ }
710
+ const summary = summarizeChecks(checks);
711
+ const ready = summary.failCount === 0;
712
+ if (options.json) {
713
+ printMachinePayload(
714
+ createMachineSuccess("doctor", {
715
+ ready,
716
+ configPath,
717
+ executionMode,
718
+ platforms,
719
+ summary,
720
+ checks
721
+ }),
722
+ options.pretty
723
+ );
724
+ } else {
725
+ printDoctorReport(summary, checks);
726
+ }
727
+ return ready;
728
+ }
729
+ export {
730
+ runDoctorCommand
731
+ };
732
+ //# sourceMappingURL=doctor-command-T2UX5RV5.js.map