@speedkit/cli 4.51.1 → 4.52.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.
Files changed (442) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +1426 -14
  3. package/dist/base/run-control-command.d.ts +15 -0
  4. package/dist/base/run-control-command.js +20 -0
  5. package/dist/build-info.json +6 -0
  6. package/dist/commands/diff.d.ts +7 -1
  7. package/dist/commands/diff.js +9 -3
  8. package/dist/commands/login.d.ts +3 -0
  9. package/dist/commands/login.js +14 -3
  10. package/dist/commands/onboarding/browser/click.d.ts +75 -0
  11. package/dist/commands/onboarding/browser/click.js +19 -0
  12. package/dist/commands/onboarding/browser/emulate.d.ts +105 -0
  13. package/dist/commands/onboarding/browser/emulate.js +26 -0
  14. package/dist/commands/onboarding/browser/navigate.d.ts +75 -0
  15. package/dist/commands/onboarding/browser/navigate.js +19 -0
  16. package/dist/commands/onboarding/browser/panel.d.ts +63 -0
  17. package/dist/commands/onboarding/browser/panel.js +12 -0
  18. package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
  19. package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
  20. package/dist/commands/onboarding/browser/reset.d.ts +71 -0
  21. package/dist/commands/onboarding/browser/reset.js +18 -0
  22. package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
  23. package/dist/commands/onboarding/browser/screenshot.js +19 -0
  24. package/dist/commands/onboarding/browser/state.d.ts +63 -0
  25. package/dist/commands/onboarding/browser/state.js +12 -0
  26. package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
  27. package/dist/commands/onboarding/browser/tabs.js +16 -0
  28. package/dist/commands/onboarding/cache/clear.d.ts +58 -0
  29. package/dist/commands/onboarding/cache/clear.js +12 -0
  30. package/dist/commands/onboarding/cache/errors.d.ts +58 -0
  31. package/dist/commands/onboarding/cache/errors.js +12 -0
  32. package/dist/commands/onboarding/cache/evict.d.ts +62 -0
  33. package/dist/commands/onboarding/cache/evict.js +15 -0
  34. package/dist/commands/onboarding/cache/get.d.ts +85 -0
  35. package/dist/commands/onboarding/cache/get.js +17 -0
  36. package/dist/commands/onboarding/cache/list.d.ts +58 -0
  37. package/dist/commands/onboarding/cache/list.js +15 -0
  38. package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
  39. package/dist/commands/onboarding/cache/prewarm.js +20 -0
  40. package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
  41. package/dist/commands/onboarding/cache/refresh.js +18 -0
  42. package/dist/commands/onboarding/cdp.d.ts +81 -0
  43. package/dist/commands/onboarding/cdp.js +18 -0
  44. package/dist/commands/onboarding/debug/arm.d.ts +83 -0
  45. package/dist/commands/onboarding/debug/arm.js +19 -0
  46. package/dist/commands/onboarding/debug/await.d.ts +71 -0
  47. package/dist/commands/onboarding/debug/await.js +18 -0
  48. package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
  49. package/dist/commands/onboarding/debug/disarm.js +12 -0
  50. package/dist/commands/onboarding/debug/eval.d.ts +75 -0
  51. package/dist/commands/onboarding/debug/eval.js +16 -0
  52. package/dist/commands/onboarding/debug/release.d.ts +63 -0
  53. package/dist/commands/onboarding/debug/release.js +12 -0
  54. package/dist/commands/onboarding/debug/resume.d.ts +63 -0
  55. package/dist/commands/onboarding/debug/resume.js +12 -0
  56. package/dist/commands/onboarding/debug/status.d.ts +63 -0
  57. package/dist/commands/onboarding/debug/status.js +12 -0
  58. package/dist/commands/onboarding/debug/step.d.ts +67 -0
  59. package/dist/commands/onboarding/debug/step.js +15 -0
  60. package/dist/commands/onboarding/files/list.d.ts +58 -0
  61. package/dist/commands/onboarding/files/list.js +12 -0
  62. package/dist/commands/onboarding/files/read.d.ts +73 -0
  63. package/dist/commands/onboarding/files/read.js +16 -0
  64. package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
  65. package/dist/commands/onboarding/files/rebuild.js +18 -0
  66. package/dist/commands/onboarding/files/validate.d.ts +58 -0
  67. package/dist/commands/onboarding/files/validate.js +12 -0
  68. package/dist/commands/onboarding/fouc.d.ts +77 -0
  69. package/dist/commands/onboarding/fouc.js +16 -0
  70. package/dist/commands/onboarding/inject/add.d.ts +89 -0
  71. package/dist/commands/onboarding/inject/add.js +17 -0
  72. package/dist/commands/onboarding/inject/clear.d.ts +63 -0
  73. package/dist/commands/onboarding/inject/clear.js +12 -0
  74. package/dist/commands/onboarding/inject/list.d.ts +63 -0
  75. package/dist/commands/onboarding/inject/list.js +12 -0
  76. package/dist/commands/onboarding/inject/read.d.ts +75 -0
  77. package/dist/commands/onboarding/inject/read.js +18 -0
  78. package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
  79. package/dist/commands/onboarding/inject/recipes.js +12 -0
  80. package/dist/commands/onboarding/inject/remove.d.ts +67 -0
  81. package/dist/commands/onboarding/inject/remove.js +15 -0
  82. package/dist/commands/onboarding/list.d.ts +13 -0
  83. package/dist/commands/onboarding/list.js +12 -0
  84. package/dist/commands/onboarding/logs.d.ts +41 -0
  85. package/dist/commands/onboarding/logs.js +257 -0
  86. package/dist/commands/onboarding/navwalk.d.ts +95 -0
  87. package/dist/commands/onboarding/navwalk.js +19 -0
  88. package/dist/commands/onboarding/response.d.ts +67 -0
  89. package/dist/commands/onboarding/response.js +18 -0
  90. package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
  91. package/dist/commands/onboarding/rum/beacons.js +16 -0
  92. package/dist/commands/onboarding/rum/get.d.ts +77 -0
  93. package/dist/commands/onboarding/rum/get.js +18 -0
  94. package/dist/commands/onboarding/rum/key.d.ts +67 -0
  95. package/dist/commands/onboarding/rum/key.js +13 -0
  96. package/dist/commands/onboarding/rum/previous.d.ts +63 -0
  97. package/dist/commands/onboarding/rum/previous.js +12 -0
  98. package/dist/commands/onboarding/status.d.ts +13 -0
  99. package/dist/commands/onboarding/status.js +17 -0
  100. package/dist/commands/onboarding/stop.d.ts +13 -0
  101. package/dist/commands/onboarding/stop.js +17 -0
  102. package/dist/commands/onboarding/todo.d.ts +58 -0
  103. package/dist/commands/onboarding/todo.js +12 -0
  104. package/dist/commands/onboarding/viewport.d.ts +101 -0
  105. package/dist/commands/onboarding/viewport.js +18 -0
  106. package/dist/commands/onboarding/watch.d.ts +93 -0
  107. package/dist/commands/onboarding/watch.js +16 -0
  108. package/dist/commands/onboarding.d.ts +26 -0
  109. package/dist/commands/onboarding.js +221 -4
  110. package/dist/commands/origin-request.d.ts +4 -0
  111. package/dist/commands/origin-request.js +4 -0
  112. package/dist/commands/spec/onboarding.spec.d.ts +1 -0
  113. package/dist/commands/spec/onboarding.spec.js +127 -0
  114. package/dist/services/browser-fetch/device-emulation.d.ts +11 -0
  115. package/dist/services/browser-fetch/device-emulation.js +14 -0
  116. package/dist/services/cli/build-info.d.ts +33 -0
  117. package/dist/services/cli/build-info.js +63 -0
  118. package/dist/services/cli/cli-environment-factory.d.ts +3 -0
  119. package/dist/services/cli/cli-environment-factory.js +1 -0
  120. package/dist/services/cli/cli-service-build-context.d.ts +3 -0
  121. package/dist/services/cli/cli-service-factory.js +1 -1
  122. package/dist/services/cli/cli-service-model.d.ts +29 -10
  123. package/dist/services/cli/cli-service.d.ts +60 -11
  124. package/dist/services/cli/cli-service.js +196 -32
  125. package/dist/services/cli/index.d.ts +2 -0
  126. package/dist/services/cli/index.js +2 -0
  127. package/dist/services/cli/sink.d.ts +47 -0
  128. package/dist/services/cli/sink.js +31 -0
  129. package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
  130. package/dist/services/cli/spec/build-identity.spec.js +85 -0
  131. package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
  132. package/dist/services/cli/spec/build-info.spec.js +10 -0
  133. package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
  134. package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
  135. package/dist/services/cli/spec/cli-service.spec.js +113 -50
  136. package/dist/services/cli/spec/memory-cli.d.ts +9 -0
  137. package/dist/services/cli/spec/memory-cli.js +9 -0
  138. package/dist/services/diff/config-at-ref.d.ts +20 -0
  139. package/dist/services/diff/config-at-ref.js +33 -0
  140. package/dist/services/diff/diff-service-build-context.d.ts +12 -0
  141. package/dist/services/diff/diff-service-build-context.js +45 -1
  142. package/dist/services/diff/diff-service-factory.d.ts +2 -0
  143. package/dist/services/diff/diff-service-factory.js +65 -25
  144. package/dist/services/diff/diff-service.d.ts +11 -0
  145. package/dist/services/diff/diff-service.js +37 -11
  146. package/dist/services/diff/page-source.d.ts +12 -0
  147. package/dist/services/diff/page-source.js +16 -11
  148. package/dist/services/diff/run-runtime-config.d.ts +33 -0
  149. package/dist/services/diff/run-runtime-config.js +74 -0
  150. package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
  151. package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
  152. package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
  153. package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
  154. package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
  155. package/dist/services/diff/spec/diff-service.spec.js +95 -0
  156. package/dist/services/diff/spec/run-runtime-config.spec.d.ts +1 -0
  157. package/dist/services/diff/spec/run-runtime-config.spec.js +87 -0
  158. package/dist/services/git/git-repository.d.ts +2 -0
  159. package/dist/services/git/git-repository.js +6 -0
  160. package/dist/services/integration-api/customer-config-flags.js +1 -0
  161. package/dist/services/onboarding/browse/browse-service.d.ts +13 -1
  162. package/dist/services/onboarding/browse/browse-service.js +43 -7
  163. package/dist/services/onboarding/browser/answer-dialogs.d.ts +12 -0
  164. package/dist/services/onboarding/browser/answer-dialogs.js +25 -0
  165. package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
  166. package/dist/services/onboarding/browser/baqend-response.js +23 -0
  167. package/dist/services/onboarding/browser/console-log.d.ts +9 -0
  168. package/dist/services/onboarding/browser/console-log.js +27 -0
  169. package/dist/services/onboarding/browser/emulate-device.d.ts +12 -1
  170. package/dist/services/onboarding/browser/emulate-device.js +68 -13
  171. package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
  172. package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
  173. package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
  174. package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
  175. package/dist/services/onboarding/browser/launch-browser.d.ts +2 -1
  176. package/dist/services/onboarding/browser/launch-browser.js +6 -1
  177. package/dist/services/onboarding/browser/resume-restarted-workers.d.ts +14 -0
  178. package/dist/services/onboarding/browser/resume-restarted-workers.js +26 -0
  179. package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
  180. package/dist/services/onboarding/control/body-inspect.js +106 -0
  181. package/dist/services/onboarding/control/browser-session.d.ts +547 -0
  182. package/dist/services/onboarding/control/browser-session.js +1337 -0
  183. package/dist/services/onboarding/control/config-validation.d.ts +17 -0
  184. package/dist/services/onboarding/control/config-validation.js +46 -0
  185. package/dist/services/onboarding/control/control-protocol.d.ts +1430 -0
  186. package/dist/services/onboarding/control/control-protocol.js +58 -0
  187. package/dist/services/onboarding/control/control-server.d.ts +292 -0
  188. package/dist/services/onboarding/control/control-server.js +1629 -0
  189. package/dist/services/onboarding/control/debug-session.d.ts +219 -0
  190. package/dist/services/onboarding/control/debug-session.js +897 -0
  191. package/dist/services/onboarding/control/fouc.d.ts +23 -0
  192. package/dist/services/onboarding/control/fouc.js +151 -0
  193. package/dist/services/onboarding/control/index.d.ts +4 -0
  194. package/dist/services/onboarding/control/index.js +4 -0
  195. package/dist/services/onboarding/control/navigate-wait.d.ts +33 -0
  196. package/dist/services/onboarding/control/navigate-wait.js +56 -0
  197. package/dist/services/onboarding/control/navwalk.d.ts +65 -0
  198. package/dist/services/onboarding/control/navwalk.js +248 -0
  199. package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
  200. package/dist/services/onboarding/control/preload-registry.js +829 -0
  201. package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
  202. package/dist/services/onboarding/control/response-explainer.js +257 -0
  203. package/dist/services/onboarding/control/rum.d.ts +8 -0
  204. package/dist/services/onboarding/control/rum.js +220 -0
  205. package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
  206. package/dist/services/onboarding/control/service-worker-tracker.js +120 -0
  207. package/dist/services/onboarding/control/viewport.d.ts +45 -0
  208. package/dist/services/onboarding/control/viewport.js +344 -0
  209. package/dist/services/onboarding/control/watch.d.ts +26 -0
  210. package/dist/services/onboarding/control/watch.js +157 -0
  211. package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
  212. package/dist/services/onboarding/dashboard/index.js +7 -2
  213. package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
  214. package/dist/services/onboarding/fetch-event-handler.js +103 -32
  215. package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
  216. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
  217. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
  218. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
  219. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
  220. package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
  221. package/dist/services/onboarding/file-events/file-watcher.js +117 -12
  222. package/dist/services/onboarding/inject/inject-service.js +1 -1
  223. package/dist/services/onboarding/onboarding-model.d.ts +40 -7
  224. package/dist/services/onboarding/onboarding-model.js +20 -9
  225. package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
  226. package/dist/services/onboarding/onboarding-service-build-context.js +7 -1
  227. package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
  228. package/dist/services/onboarding/onboarding-service-factory.js +150 -23
  229. package/dist/services/onboarding/onboarding-service.d.ts +40 -1
  230. package/dist/services/onboarding/onboarding-service.js +139 -23
  231. package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
  232. package/dist/services/onboarding/request-cache/asset-key.js +115 -0
  233. package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
  234. package/dist/services/onboarding/request-cache/cache.js +128 -17
  235. package/dist/services/onboarding/spec/browser/answer-dialogs.spec.d.ts +1 -0
  236. package/dist/services/onboarding/spec/browser/answer-dialogs.spec.js +66 -0
  237. package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
  238. package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
  239. package/dist/services/onboarding/spec/browser/resume-restarted-workers.spec.d.ts +1 -0
  240. package/dist/services/onboarding/spec/browser/resume-restarted-workers.spec.js +45 -0
  241. package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
  242. package/dist/services/onboarding/spec/control/browser-session.spec.js +753 -0
  243. package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
  244. package/dist/services/onboarding/spec/control/control-server.spec.js +371 -0
  245. package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
  246. package/dist/services/onboarding/spec/control/debug-session.spec.js +751 -0
  247. package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
  248. package/dist/services/onboarding/spec/control/fakes.js +67 -0
  249. package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
  250. package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
  251. package/dist/services/onboarding/spec/control/navigate-wait.spec.d.ts +1 -0
  252. package/dist/services/onboarding/spec/control/navigate-wait.spec.js +47 -0
  253. package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
  254. package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
  255. package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
  256. package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
  257. package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
  258. package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
  259. package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
  260. package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
  261. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
  262. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
  263. package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
  264. package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
  265. package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
  266. package/dist/services/onboarding/spec/control/watch.spec.js +187 -0
  267. package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
  268. package/dist/services/onboarding/spec/fetch-event-handler.spec.js +219 -0
  269. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
  270. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
  271. package/dist/services/onboarding/spec/onboarding-model.spec.js +39 -3
  272. package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +25 -1
  273. package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
  274. package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
  275. package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
  276. package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
  277. package/dist/services/onboarding/spec/virtual-orestes-app/virtual-orestes-app.spec.d.ts +1 -0
  278. package/dist/services/onboarding/spec/virtual-orestes-app/virtual-orestes-app.spec.js +65 -0
  279. package/dist/services/onboarding/templates/install-speed-kit-html-template.js +11 -0
  280. package/dist/services/onboarding/templates/spec/install-speed-kit-html-template.spec.d.ts +1 -0
  281. package/dist/services/onboarding/templates/spec/install-speed-kit-html-template.spec.js +119 -0
  282. package/dist/services/onboarding/todo-collector.d.ts +7 -2
  283. package/dist/services/onboarding/todo-collector.js +49 -12
  284. package/dist/services/onboarding/virtual-orestes-app/index.d.ts +38 -0
  285. package/dist/services/onboarding/virtual-orestes-app/index.js +113 -27
  286. package/dist/services/origin-request/asset-variations.d.ts +14 -0
  287. package/dist/services/origin-request/asset-variations.js +11 -4
  288. package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
  289. package/dist/services/origin-request/origin-fetcher.js +43 -5
  290. package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
  291. package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
  292. package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
  293. package/dist/services/origin-request/origin-request-service-factory.js +2 -30
  294. package/dist/services/origin-request/origin-request-service.d.ts +121 -6
  295. package/dist/services/origin-request/origin-request-service.js +273 -49
  296. package/dist/services/origin-request/runtime-config-source.d.ts +6 -0
  297. package/dist/services/origin-request/runtime-config-source.js +15 -4
  298. package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
  299. package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
  300. package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
  301. package/dist/services/query-builder/rules/rule-match.js +70 -0
  302. package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
  303. package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
  304. package/dist/services/run-control/browser/run-browser-contexts.d.ts +557 -0
  305. package/dist/services/run-control/browser/run-browser-contexts.js +91 -0
  306. package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
  307. package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
  308. package/dist/services/run-control/browser/run-browser-service.d.ts +68 -0
  309. package/dist/services/run-control/browser/run-browser-service.js +206 -0
  310. package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
  311. package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
  312. package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
  313. package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
  314. package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
  315. package/dist/services/run-control/cache/run-cache-service.js +151 -0
  316. package/dist/services/run-control/control-client.d.ts +36 -0
  317. package/dist/services/run-control/control-client.js +147 -0
  318. package/dist/services/run-control/debug/run-debug-contexts.d.ts +416 -0
  319. package/dist/services/run-control/debug/run-debug-contexts.js +47 -0
  320. package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
  321. package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
  322. package/dist/services/run-control/debug/run-debug-service.d.ts +39 -0
  323. package/dist/services/run-control/debug/run-debug-service.js +164 -0
  324. package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
  325. package/dist/services/run-control/files/run-files-contexts.js +26 -0
  326. package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
  327. package/dist/services/run-control/files/run-files-service-factory.js +7 -0
  328. package/dist/services/run-control/files/run-files-service.d.ts +29 -0
  329. package/dist/services/run-control/files/run-files-service.js +120 -0
  330. package/dist/services/run-control/index.d.ts +32 -0
  331. package/dist/services/run-control/index.js +31 -0
  332. package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
  333. package/dist/services/run-control/inject/run-inject-contexts.js +38 -0
  334. package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
  335. package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
  336. package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
  337. package/dist/services/run-control/inject/run-inject-service.js +227 -0
  338. package/dist/services/run-control/live-run.d.ts +37 -0
  339. package/dist/services/run-control/live-run.js +56 -0
  340. package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
  341. package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
  342. package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
  343. package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
  344. package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
  345. package/dist/services/run-control/probe/run-probe-service.js +194 -0
  346. package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
  347. package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
  348. package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
  349. package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
  350. package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
  351. package/dist/services/run-control/rum/run-rum-service.js +122 -0
  352. package/dist/services/run-control/run-answer.d.ts +28 -0
  353. package/dist/services/run-control/run-answer.js +58 -0
  354. package/dist/services/run-control/run-control-context.d.ts +102 -0
  355. package/dist/services/run-control/run-control-context.js +36 -0
  356. package/dist/services/run-control/run-control-flags.d.ts +12 -0
  357. package/dist/services/run-control/run-control-flags.js +22 -0
  358. package/dist/services/run-control/run-control-model.d.ts +9 -0
  359. package/dist/services/run-control/run-control-model.js +1 -0
  360. package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
  361. package/dist/services/run-control/run-control-service-factory.js +26 -0
  362. package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
  363. package/dist/services/run-control/session/run-session-contexts.js +20 -0
  364. package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
  365. package/dist/services/run-control/session/run-session-service-factory.js +18 -0
  366. package/dist/services/run-control/session/run-session-service.d.ts +32 -0
  367. package/dist/services/run-control/session/run-session-service.js +151 -0
  368. package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
  369. package/dist/services/run-control/spec/browser/run-browser-service.spec.js +328 -0
  370. package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
  371. package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
  372. package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
  373. package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
  374. package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
  375. package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
  376. package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
  377. package/dist/services/run-control/spec/inject/run-inject-service.spec.js +251 -0
  378. package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
  379. package/dist/services/run-control/spec/live-run-fixture.js +109 -0
  380. package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
  381. package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
  382. package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
  383. package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
  384. package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
  385. package/dist/services/run-control/spec/run-answer.spec.js +57 -0
  386. package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
  387. package/dist/services/run-control/spec/session/run-session-service.spec.js +150 -0
  388. package/dist/services/run-log/crash-mirror.d.ts +31 -0
  389. package/dist/services/run-log/crash-mirror.js +69 -0
  390. package/dist/services/run-log/index.d.ts +11 -0
  391. package/dist/services/run-log/index.js +11 -0
  392. package/dist/services/run-log/jsonl-appender.d.ts +46 -0
  393. package/dist/services/run-log/jsonl-appender.js +91 -0
  394. package/dist/services/run-log/log-event-model.d.ts +104 -0
  395. package/dist/services/run-log/log-event-model.js +56 -0
  396. package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
  397. package/dist/services/run-log/log-query-service-factory.js +14 -0
  398. package/dist/services/run-log/log-query-service.d.ts +59 -0
  399. package/dist/services/run-log/log-query-service.js +111 -0
  400. package/dist/services/run-log/log-reader.d.ts +84 -0
  401. package/dist/services/run-log/log-reader.js +180 -0
  402. package/dist/services/run-log/log-summary.d.ts +72 -0
  403. package/dist/services/run-log/log-summary.js +208 -0
  404. package/dist/services/run-log/redaction.d.ts +34 -0
  405. package/dist/services/run-log/redaction.js +124 -0
  406. package/dist/services/run-log/request-log.d.ts +82 -0
  407. package/dist/services/run-log/request-log.js +69 -0
  408. package/dist/services/run-log/request-summary.d.ts +76 -0
  409. package/dist/services/run-log/request-summary.js +0 -0
  410. package/dist/services/run-log/run-log.d.ts +61 -0
  411. package/dist/services/run-log/run-log.js +102 -0
  412. package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
  413. package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
  414. package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
  415. package/dist/services/run-log/spec/log-reader.spec.js +109 -0
  416. package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
  417. package/dist/services/run-log/spec/log-summary.spec.js +153 -0
  418. package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
  419. package/dist/services/run-log/spec/redaction.spec.js +61 -0
  420. package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
  421. package/dist/services/run-log/spec/request-log.spec.js +101 -0
  422. package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
  423. package/dist/services/run-log/spec/request-summary.spec.js +171 -0
  424. package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
  425. package/dist/services/run-log/spec/run-log.spec.js +122 -0
  426. package/dist/services/run-registry/exit-classification.d.ts +39 -0
  427. package/dist/services/run-registry/exit-classification.js +42 -0
  428. package/dist/services/run-registry/index.d.ts +3 -0
  429. package/dist/services/run-registry/index.js +3 -0
  430. package/dist/services/run-registry/process-identity.d.ts +28 -0
  431. package/dist/services/run-registry/process-identity.js +80 -0
  432. package/dist/services/run-registry/run-registry-model.d.ts +128 -0
  433. package/dist/services/run-registry/run-registry-model.js +16 -0
  434. package/dist/services/run-registry/run-registry.d.ts +155 -0
  435. package/dist/services/run-registry/run-registry.js +430 -0
  436. package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
  437. package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
  438. package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
  439. package/dist/services/run-registry/spec/run-registry.spec.js +526 -0
  440. package/dist/services/setup/os/tool-registry.js +2 -2
  441. package/oclif.manifest.json +3414 -293
  442. package/package.json +20 -2
@@ -12,6 +12,9 @@ import { assertCustomerOrigin } from "./customer-origin.js";
12
12
  import { stderrLog } from "./diff-log.js";
13
13
  import { variationPair, } from "./diff-service-build-context.js";
14
14
  import { DiffService } from "./diff-service.js";
15
+ import { configAtRef } from "./config-at-ref.js";
16
+ import { RunRegistry } from "../run-registry/index.js";
17
+ import { DEFAULTS_ONLY, diffRuntimeConfig, liveRunFor, } from "./run-runtime-config.js";
15
18
  import { PageSource } from "./page-source.js";
16
19
  /**
17
20
  * The variations a person can choose from: the device variations and the
@@ -47,8 +50,11 @@ export class DiffServiceFactory {
47
50
  async build() {
48
51
  const { environment } = this.context;
49
52
  const chosenParameters = await this.withChosenParameters();
50
- const json = this.context.output === "json";
51
- const log = json ? stderrLog(environment.cli) : environment.cli;
53
+ // JSON and a patch own stdout; the progress goes to stderr.
54
+ const ownsStdout = ["json", "patch"].includes(this.context.output);
55
+ const log = ownsStdout
56
+ ? stderrLog(environment.cli)
57
+ : environment.cli;
52
58
  const files = this.context.customerPath
53
59
  ? await this.getIntegrationFiles()
54
60
  : undefined;
@@ -59,13 +65,40 @@ export class DiffServiceFactory {
59
65
  for (const url of [pageUrl, against].filter(Boolean)) {
60
66
  assertCustomerOrigin(url, customer.origins, this.context.customerPath);
61
67
  }
62
- applyOriginProxy(customer.chromeFlags, json ? undefined : environment.cli);
63
- }
64
- const config = await this.loadRuntimeConfig(log, customer?.app);
65
- if (!config) {
66
- throw new ApplicationError("no runtime config to build the requests from");
68
+ applyOriginProxy(customer.chromeFlags, ownsStdout ? undefined : environment.cli);
67
69
  }
70
+ const config = await diffRuntimeConfig({
71
+ log,
72
+ // A named file wins; else the live run the customer has, so the diff sees what it sees.
73
+ run: this.context.variationsFile
74
+ ? undefined
75
+ : liveRunFor({
76
+ registry: new RunRegistry(environment.cacheDir),
77
+ selector: this.context.run,
78
+ customerPath: this.context.customerPath,
79
+ }),
80
+ runNamed: Boolean(this.context.run),
81
+ file: this.context.variationsFile,
82
+ load: () => this.loadRuntimeConfig(log, customer?.app),
83
+ });
68
84
  const options = await this.withChosenVariations(chosenParameters, config.variations);
85
+ const fetcher = new OriginFetcher({
86
+ cli: log,
87
+ config,
88
+ host: this.context.host,
89
+ strict: true,
90
+ });
91
+ const ignore = this.context.ignore.map((pattern) => new RegExp(pattern, "g"));
92
+ const pages = new PageSource({
93
+ fetcher,
94
+ documentHandler: this.context.raw || !files
95
+ ? undefined
96
+ : await this.buildDocumentHandler(files, this.context.customerPath),
97
+ ignore,
98
+ });
99
+ const base = this.context.base
100
+ ? await this.buildBase(log, fetcher, ignore)
101
+ : undefined;
69
102
  // Installed last, after everything that can fail: the service closes it.
70
103
  const browserFetch = this.context.browserFetch
71
104
  ? installBrowserOriginFetch({ environment, logger: log, mode: "always" })
@@ -77,21 +110,28 @@ export class DiffServiceFactory {
77
110
  options,
78
111
  log,
79
112
  browserFetch,
113
+ base,
80
114
  engine: createDiffEngine(environment, this.context.output),
81
- pages: new PageSource({
82
- fetcher: new OriginFetcher({
83
- cli: log,
84
- config,
85
- host: this.context.host,
86
- strict: true,
87
- }),
88
- documentHandler: this.context.raw || !files
89
- ? undefined
90
- : await this.buildDocumentHandler(files),
91
- ignore: this.context.ignore.map((pattern) => new RegExp(pattern, "g")),
92
- }),
115
+ pages,
93
116
  });
94
117
  }
118
+ /** The pages rendered with the customer config at `--base`, from a checkout of it. */
119
+ async buildBase(log, fetcher, ignore) {
120
+ const checkout = await configAtRef(this.context.customerPath, this.context.base);
121
+ log.comment(`--base ${this.context.base}: the config at ${checkout.commit.slice(0, 8)}, where HEAD left it`);
122
+ try {
123
+ const files = await this.getIntegrationFiles(checkout.customerPath);
124
+ const documentHandler = await this.buildDocumentHandler(files, checkout.customerPath);
125
+ return {
126
+ pages: new PageSource({ fetcher, documentHandler, ignore }),
127
+ remove: checkout.remove,
128
+ };
129
+ }
130
+ catch (error) {
131
+ await checkout.remove();
132
+ throw error;
133
+ }
134
+ }
95
135
  /**
96
136
  * The options, with the parameters an empty `--param` asked for added to
97
137
  * the ones removed. Asked first, before anything is loaded or fetched.
@@ -123,7 +163,7 @@ export class DiffServiceFactory {
123
163
  const chosen = await this.context.environment.cli.multiSelect("Which variations should be compared? One is compared against desktop", variationChoices(variations), (picked) => (picked.length === 1 && picked[0] !== DEFAULT_TYPE) ||
124
164
  picked.length === 2 ||
125
165
  "Choose one variation to compare against desktop, or two to compare with each other.");
126
- // A quiet CLI (--output json) does not ask, and answers with no choice.
166
+ // A quiet CLI (--output json or patch) does not ask, and answers with no choice.
127
167
  if (chosen.length === 0) {
128
168
  throw new ApplicationError("No variation chosen, so nothing to compare.", ["Name them: --variations mobile, or --variations tablet,mobile"]);
129
169
  }
@@ -145,7 +185,7 @@ export class DiffServiceFactory {
145
185
  async loadRuntimeConfig(log, app) {
146
186
  if (!app && !this.context.variationsFile) {
147
187
  log.writeWarning("no customer: the requests carry Speed Kit's device defaults only, no variations of an app");
148
- return { variations: {}, authentications: [], originMap: {} };
188
+ return DEFAULTS_ONLY;
149
189
  }
150
190
  return new RuntimeConfigSource({
151
191
  cli: log,
@@ -156,20 +196,20 @@ export class DiffServiceFactory {
156
196
  }).load(this.context.variationsFile);
157
197
  }
158
198
  /** The customer's files, with the released document handler unless it brings its own. */
159
- async getIntegrationFiles() {
199
+ async getIntegrationFiles(customerPath = this.context.customerPath) {
160
200
  return new IntegrationApiFactory(new IntegrationApiServiceBuildContext({
161
201
  environment: this.context.environment,
162
- basePath: this.context.customerPath,
202
+ basePath: customerPath,
163
203
  configName: this.context.configName,
164
204
  whitelist: [],
165
205
  }))
166
206
  .buildService()
167
207
  .run(this.context.raw ? [] : documentHandlerRuntimeFiles());
168
208
  }
169
- async buildDocumentHandler(files) {
209
+ async buildDocumentHandler(files, customerPath) {
170
210
  return new DocumentHandlerRuntimeServiceFactory(new DocumentHandlerRuntimeServiceBuildContext({
171
211
  environment: this.context.environment,
172
- customerPath: this.context.customerPath,
212
+ customerPath,
173
213
  configName: this.context.configName,
174
214
  verboseLevel: false,
175
215
  }), files).buildDocumentHandlerServer();
@@ -11,6 +11,11 @@ export interface DiffServiceDeps {
11
11
  readonly pages: PageSource;
12
12
  /** The headless Chrome pages are fetched through; closed when the run ends. */
13
13
  readonly browserFetch?: BrowserOriginFetchHandle;
14
+ /** With `--base`: the pages rendered with the config at that ref, and how to remove its checkout. */
15
+ readonly base?: {
16
+ readonly pages: PageSource;
17
+ remove(): Promise<void>;
18
+ };
14
19
  }
15
20
  /**
16
21
  * `sk diff`: compares one page, as Speed Kit's server would request and the
@@ -60,6 +65,12 @@ export declare class DiffService {
60
65
  */
61
66
  run(): Promise<ComparisonOutcome>;
62
67
  private check;
68
+ /**
69
+ * One origin page, rendered with the config at `--base` and with the
70
+ * working tree: only what the config change does. The page is requested
71
+ * once, or read from `--html`; an origin failure ends the run.
72
+ */
73
+ private checkBase;
63
74
  /** The page against another page, both in one variation. */
64
75
  private checkAgainst;
65
76
  private checkVariations;
@@ -1,9 +1,16 @@
1
+ import { readFile } from "node:fs/promises";
1
2
  import { withoutNoise } from "./noise-baseline.js";
2
3
  import ApplicationError from "../error-handling/error/application-error.js";
3
4
  import { PageSideFailure } from "./side-failure.js";
4
5
  function isFailed(side) {
5
6
  return side !== undefined && "failure" in side;
6
7
  }
8
+ /** The side a failure Speed Kit's server would also have leaves; any other error ends the run. */
9
+ function failedPage(error, label, url, variation) {
10
+ if (!(error instanceof PageSideFailure))
11
+ throw error;
12
+ return { label, failure: error.failure, details: { url, variation }, error };
13
+ }
7
14
  /** The failed side as a sink reports it, without the error object. */
8
15
  function withoutError({ error: _error, ...side }) {
9
16
  return side;
@@ -81,11 +88,16 @@ export class DiffService {
81
88
  finally {
82
89
  this.deps.engine.finish();
83
90
  await this.deps.browserFetch?.close();
91
+ await this.deps.base?.remove();
84
92
  }
85
93
  return (OUTCOME_RANK.find((outcome) => this.outcomes.has(outcome)) ?? "equal");
86
94
  }
87
95
  async check() {
88
96
  const { against, variation, variations, params } = this.deps.options;
97
+ if (this.deps.base) {
98
+ await this.checkBase(this.deps.base.pages, variation);
99
+ return;
100
+ }
89
101
  if (against) {
90
102
  await this.checkAgainst(against, variation);
91
103
  return;
@@ -102,6 +114,27 @@ export class DiffService {
102
114
  await this.checkParameters(each);
103
115
  }
104
116
  }
117
+ /**
118
+ * One origin page, rendered with the config at `--base` and with the
119
+ * working tree: only what the config change does. The page is requested
120
+ * once, or read from `--html`; an origin failure ends the run.
121
+ */
122
+ async checkBase(basePages, variation) {
123
+ const { pageUrl, base, html } = this.deps.options;
124
+ const page = html === undefined
125
+ ? await this.deps.pages.origin(pageUrl, variation)
126
+ : { html: await readFile(html, "utf8") };
127
+ const render = (pages, label) => pages
128
+ .fromHtml(page.html, pageUrl, variation, {
129
+ label,
130
+ contentType: page.contentType,
131
+ })
132
+ .catch((error) => failedPage(error, label, pageUrl, variation));
133
+ const before = await render(basePages, `config at ${base}`);
134
+ const after = await render(this.deps.pages, "working tree");
135
+ this.announce(`Checking the working tree against ${base} (${variation})...`, [`- url: ${pageUrl}`, ...(html === undefined ? [] : [`- html: ${html}`])]);
136
+ await this.compare(before, after);
137
+ }
105
138
  /** The page against another page, both in one variation. */
106
139
  async checkAgainst(against, variation) {
107
140
  const { pageUrl } = this.deps.options;
@@ -237,7 +270,9 @@ export class DiffService {
237
270
  reportFailure(left, right) {
238
271
  const { log, engine } = this.deps;
239
272
  const failed = [left, right].filter(isFailed);
240
- const outcome = failed.every((side) => side.error.isAbort)
273
+ // With --base, any rendering failure is the config change's verdict.
274
+ const verdict = (error) => this.deps.base ? error.failure.kind !== "origin" : error.isAbort;
275
+ const outcome = failed.every((side) => verdict(side.error))
241
276
  ? "uncacheable"
242
277
  : "failed";
243
278
  for (const { error } of failed) {
@@ -281,16 +316,7 @@ export class DiffService {
281
316
  if (!side) {
282
317
  side = this.deps.pages
283
318
  .fetch(url, variation, label, { baseline: this.deps.options.baseline })
284
- .catch((error) => {
285
- if (!(error instanceof PageSideFailure))
286
- throw error;
287
- return {
288
- label,
289
- failure: error.failure,
290
- details: { url, variation },
291
- error,
292
- };
293
- });
319
+ .catch((error) => failedPage(error, label, url, variation));
294
320
  this.sides.set(key, side);
295
321
  }
296
322
  return side;
@@ -19,6 +19,13 @@ export interface PageSourceOptions {
19
19
  */
20
20
  readonly baseline?: boolean;
21
21
  }
22
+ /** A page as the origin answered it. */
23
+ export interface OriginPage {
24
+ readonly html: string;
25
+ readonly contentType?: string;
26
+ /** Where the request went and what it answered, for a sink that reports it. */
27
+ readonly details?: Readonly<Record<string, unknown>>;
28
+ }
22
29
  /**
23
30
  * One side of a page diff: the page fetched from origin as Speed Kit's server
24
31
  * requests it for a variation, rendered by the customer's local
@@ -29,6 +36,11 @@ export declare class PageSource {
29
36
  constructor(deps: PageSourceDeps);
30
37
  fetch(url: string, variation: string, label: string, options?: PageSourceOptions): Promise<BaselinedSide>;
31
38
  private fetchOnce;
39
+ /**
40
+ * The page as the origin answers Speed Kit's server, before the
41
+ * documentHandler renders it.
42
+ */
43
+ origin(url: string, variation: string): Promise<OriginPage>;
32
44
  /**
33
45
  * A side from HTML the caller already has, such as the page a browser
34
46
  * shows: rendered and reduced the same way a fetched page is.
@@ -23,6 +23,19 @@ export class PageSource {
23
23
  return { ...side, baseline: baselineOf(side.content, again.content) };
24
24
  }
25
25
  async fetchOnce(url, variation, label, options) {
26
+ const page = await this.origin(url, variation);
27
+ const side = await this.fromHtml(page.html, url, variation, {
28
+ ...options,
29
+ label,
30
+ contentType: page.contentType,
31
+ });
32
+ return { ...side, details: { ...side.details, ...page.details } };
33
+ }
34
+ /**
35
+ * The page as the origin answers Speed Kit's server, before the
36
+ * documentHandler renders it.
37
+ */
38
+ async origin(url, variation) {
26
39
  const fetched = await this.deps.fetcher.fetch(url, variation);
27
40
  if (!fetched) {
28
41
  throw new ApplicationError(`${url} (${variation}) could not be fetched.`);
@@ -38,18 +51,10 @@ export class PageSource {
38
51
  failure: originFailure(response.status, response.statusText),
39
52
  });
40
53
  }
41
- const side = await this.fromHtml(await response.text(), url, variation, {
42
- ...options,
43
- label,
44
- contentType: response.headers.get("content-type") ?? undefined,
45
- });
46
54
  return {
47
- ...side,
48
- details: {
49
- ...side.details,
50
- requestUrl: fetched.url,
51
- status: response.status,
52
- },
55
+ html: await response.text(),
56
+ contentType: response.headers.get("content-type") ?? undefined,
57
+ details: { requestUrl: fetched.url, status: response.status },
53
58
  };
54
59
  }
55
60
  /**
@@ -0,0 +1,33 @@
1
+ import { OriginRequestConfig } from "../origin-request/index.js";
2
+ import { LiveRun } from "../run-control/live-run.js";
3
+ import { RunRegistry } from "../run-registry/index.js";
4
+ import { DiffLog } from "./diff-log.js";
5
+ /** What a request carries without a runtime config: the device defaults only. */
6
+ export declare const DEFAULTS_ONLY: OriginRequestConfig;
7
+ /**
8
+ * The live run whose runtime config `sk diff` follows: the one `--run` names,
9
+ * else the one live run of the customer. Several live runs pick none.
10
+ */
11
+ export declare function liveRunFor(input: {
12
+ registry: RunRegistry;
13
+ selector?: string;
14
+ customerPath?: string;
15
+ }): LiveRun | undefined;
16
+ export interface DiffRuntimeConfigDeps {
17
+ readonly log: DiffLog;
18
+ /** The live run to follow; absent without one. */
19
+ readonly run?: Pick<LiveRun, "id" | "request">;
20
+ /** Whether `--run` named the run, so a failure to ask it is not hidden. */
21
+ readonly runNamed?: boolean;
22
+ /** `--variationsFile`: the file `load` reads instead of the app's config. */
23
+ readonly file?: string;
24
+ /** The app's or the file's runtime config, as `RuntimeConfigSource` loads it. */
25
+ readonly load: () => Promise<OriginRequestConfig | undefined>;
26
+ }
27
+ /**
28
+ * The runtime config `sk diff` builds its requests from: the live run's, so
29
+ * the diff sees what the run sees, else the one `load` reads.
30
+ *
31
+ * @throws {ApplicationError} Without a config: the run loaded none, or `load` read none.
32
+ */
33
+ export declare function diffRuntimeConfig(deps: DiffRuntimeConfigDeps): Promise<OriginRequestConfig>;
@@ -0,0 +1,74 @@
1
+ import { resolve } from "node:path";
2
+ import ApplicationError from "../error-handling/error/application-error.js";
3
+ import { ControlError } from "../run-control/control-client.js";
4
+ import { LiveRun } from "../run-control/live-run.js";
5
+ /** What a request carries without a runtime config: the device defaults only. */
6
+ export const DEFAULTS_ONLY = {
7
+ variations: {},
8
+ authentications: [],
9
+ originMap: {},
10
+ };
11
+ /**
12
+ * The live run whose runtime config `sk diff` follows: the one `--run` names,
13
+ * else the one live run of the customer. Several live runs pick none.
14
+ */
15
+ export function liveRunFor(input) {
16
+ const { registry, selector, customerPath } = input;
17
+ if (selector)
18
+ return LiveRun.resolve(registry, selector);
19
+ if (!customerPath)
20
+ return undefined;
21
+ const wanted = resolve(customerPath);
22
+ const runs = registry
23
+ .liveRuns()
24
+ .filter((run) => (run.meta.customerDir ?? resolve(run.meta.customerPath)) === wanted);
25
+ return runs.length === 1 ? new LiveRun(runs[0]) : undefined;
26
+ }
27
+ /**
28
+ * The runtime config `sk diff` builds its requests from: the live run's, so
29
+ * the diff sees what the run sees, else the one `load` reads.
30
+ *
31
+ * @throws {ApplicationError} Without a config: the run loaded none, or `load` read none.
32
+ */
33
+ export async function diffRuntimeConfig(deps) {
34
+ const { log, run, runNamed, file, load } = deps;
35
+ if (run) {
36
+ try {
37
+ const { config } = await run.request({
38
+ op: "config.runtime",
39
+ });
40
+ if (config) {
41
+ log.comment(`runtime config from the live run ${run.id}`);
42
+ return config;
43
+ }
44
+ // The device defaults would hide that the run lacks the variations and the basic auth.
45
+ throw noRuntimeConfig(`the live run ${run.id} loaded no runtime config`, [
46
+ 'Run "sk login", then restart the run so it loads the runtime config.',
47
+ ]);
48
+ }
49
+ catch (error) {
50
+ // A run of an older build does not know the op; the login still works.
51
+ if (runNamed || !(error instanceof ControlError))
52
+ throw error;
53
+ log.comment(`the live run ${run.id} did not share its runtime config (${error.message}); loading the app's`);
54
+ }
55
+ }
56
+ const config = await load();
57
+ if (!config && file) {
58
+ throw new ApplicationError(`no runtime config to build the requests from: ${file} could not be read`);
59
+ }
60
+ if (!config) {
61
+ throw noRuntimeConfig("no login", [
62
+ 'Run "sk login".',
63
+ "Or pass --run <run> to take it from a live sk onboarding run.",
64
+ ]);
65
+ }
66
+ return config;
67
+ }
68
+ /** The refusal without a runtime config; `--variationsFile` always fixes it. */
69
+ function noRuntimeConfig(cause, fixes) {
70
+ return new ApplicationError(`no runtime config to build the requests from: ${cause}`, [
71
+ ...fixes,
72
+ "Or pass --variationsFile <file> to use a config you already have.",
73
+ ]);
74
+ }
@@ -11,8 +11,9 @@ export interface ToolDiffSinkDeps {
11
11
  * IntelliJ IDEA when none is configured.
12
12
  *
13
13
  * Both sides are written to files under the CLI's cache directory, which
14
- * outlive the command: the tool opens them after `idea diff` has returned.
15
- * The right side is read back, so an edit made in the tool reaches the caller.
14
+ * outlive the command. The right side is read back once the command returns,
15
+ * so an edit made in the tool reaches the caller only when the command blocks
16
+ * until the diff is closed: `idea diff` does, VS Code needs `--wait`.
16
17
  */
17
18
  export declare class ToolDiffSink implements DiffSink {
18
19
  private readonly deps;
@@ -18,8 +18,9 @@ function fileName(label) {
18
18
  * IntelliJ IDEA when none is configured.
19
19
  *
20
20
  * Both sides are written to files under the CLI's cache directory, which
21
- * outlive the command: the tool opens them after `idea diff` has returned.
22
- * The right side is read back, so an edit made in the tool reaches the caller.
21
+ * outlive the command. The right side is read back once the command returns,
22
+ * so an edit made in the tool reaches the caller only when the command blocks
23
+ * until the diff is closed: `idea diff` does, VS Code needs `--wait`.
23
24
  */
24
25
  export class ToolDiffSink {
25
26
  deps;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,46 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { expect } from "chai";
4
+ import { describe, it } from "mocha";
5
+ import { GitRepository } from "../../git/index.js";
6
+ import { configAtRef } from "../config-at-ref.js";
7
+ /** A repository whose merge base with any ref is `fork`, and holds the files in `files`. */
8
+ function repositoryWith(files, seen = []) {
9
+ return new GitRepository("/repo", (args) => {
10
+ seen.push(args);
11
+ if (args[0] === "merge-base")
12
+ return "f0f0f0f0f0\n";
13
+ if (args[0] === "ls-tree")
14
+ return Object.keys(files).join("\n");
15
+ if (args[0] === "show")
16
+ return files[args[1].split(":")[1]];
17
+ throw new Error(`unexpected git ${args.join(" ")}`);
18
+ });
19
+ }
20
+ describe("configAtRef", () => {
21
+ it("writes the customer directory as the ref holds it, and removes it", async () => {
22
+ const checkout = await configAtRef("/repo/customers/shop", "origin/main", repositoryWith({
23
+ "customers/shop/config_customer.json": '{"app":"shop"}',
24
+ "customers/shop/plugins/grid.js": "export {}",
25
+ }));
26
+ expect(checkout.customerPath).to.match(/customers[/\\]shop$/);
27
+ expect(readFileSync(path.join(checkout.customerPath, "plugins/grid.js"), "utf8")).to.equal("export {}");
28
+ await checkout.remove();
29
+ expect(existsSync(checkout.customerPath)).to.equal(false);
30
+ });
31
+ it("refuses a ref without the customer", async () => {
32
+ const error = await configAtRef("/repo/customers/new", "origin/main", repositoryWith({})).catch((error_) => error_);
33
+ expect(error.message).to.contain("no config at origin/main (f0f0f0f0) for customers/new");
34
+ });
35
+ it("reads the files where HEAD left the ref, so later changes on it do not show reversed", async () => {
36
+ const seen = [];
37
+ const checkout = await configAtRef("/repo/customers/shop", "origin/main", repositoryWith({ "customers/shop/config_customer.json": "{}" }, seen));
38
+ await checkout.remove();
39
+ expect(seen[0]).to.deep.equal(["merge-base", "HEAD", "origin/main"]);
40
+ expect(checkout.commit).to.equal("f0f0f0f0f0");
41
+ expect(seen.slice(1).map((args) => args.at(-1))).to.deep.equal([
42
+ "customers/shop",
43
+ "f0f0f0f0f0:customers/shop/config_customer.json",
44
+ ]);
45
+ });
46
+ });
@@ -37,6 +37,25 @@ describe("DiffServiceBuildContext", () => {
37
37
  it("refuses --against the page itself", () => {
38
38
  expect(() => create({ against: "https://shop.test/" })).to.throw("with itself");
39
39
  });
40
+ it("renders the page with the config at --base, from --html in one variation", () => {
41
+ const context = create({
42
+ base: "origin/main",
43
+ html: "page.html",
44
+ variation: "mobile",
45
+ });
46
+ expect(context.base).to.equal("origin/main");
47
+ expect(context.html).to.equal("page.html");
48
+ expect(context.variation).to.equal("mobile");
49
+ });
50
+ it("refuses --base with the flags of the checks it replaces", () => {
51
+ expect(() => create({ base: "origin/main", params: true, baseline: true })).to.throw("does not take --params, --baseline");
52
+ });
53
+ it("refuses --base with --raw, which has no documentHandler", () => {
54
+ expect(() => create({ base: "origin/main", raw: true })).to.throw("needs the customer path and the documentHandler");
55
+ });
56
+ it("refuses --html without --base", () => {
57
+ expect(() => create({ html: "page.html" })).to.throw("for --base");
58
+ });
40
59
  it("refuses --variation next to --variations", () => {
41
60
  expect(() => create({ variation: "mobile", variations: ["tablet"] })).to.throw("pass one of them");
42
61
  });
@@ -1,3 +1,6 @@
1
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import path from "node:path";
1
4
  import { expect } from "chai";
2
5
  import { describe, it } from "mocha";
3
6
  import { DiffEngine } from "../diff-engine.js";
@@ -407,3 +410,95 @@ describe("DiffService variation", () => {
407
410
  ]);
408
411
  });
409
412
  });
413
+ /** A page source that renders whatever origin HTML it is given with `render`. */
414
+ function renderingSource(render) {
415
+ const origins = [];
416
+ const source = {
417
+ origins,
418
+ async origin(url, variation) {
419
+ origins.push(`${variation} ${url}`);
420
+ return { html: "<p>origin</p>" };
421
+ },
422
+ async fromHtml(html, _url, _variation, options) {
423
+ const content = render(html);
424
+ if (content instanceof PageSideFailure)
425
+ throw content;
426
+ return { label: options.label, content };
427
+ },
428
+ };
429
+ return source;
430
+ }
431
+ function baseService(before, after, options = {}) {
432
+ const shown = [];
433
+ const failed = [];
434
+ const removed = [];
435
+ const log = recordingLog();
436
+ const pages = renderingSource(after);
437
+ const diff = new DiffService({
438
+ options: {
439
+ pageUrl: "https://shop.test/c/shoes",
440
+ variation: "default",
441
+ base: "origin/main",
442
+ ...options,
443
+ },
444
+ log,
445
+ engine: new DiffEngine({
446
+ sink: {
447
+ async show(result) {
448
+ shown.push(result);
449
+ return undefined;
450
+ },
451
+ fail(comparison) {
452
+ failed.push(comparison);
453
+ },
454
+ },
455
+ }),
456
+ pages,
457
+ base: {
458
+ pages: renderingSource(before),
459
+ remove: async () => {
460
+ removed.push("base");
461
+ },
462
+ },
463
+ });
464
+ return { diff, shown, failed, removed, log, pages };
465
+ }
466
+ describe("DiffService base", () => {
467
+ it("renders one origin page with both configs and shows the change", async () => {
468
+ const { diff, shown, removed, pages } = baseService((html) => `${html}<p>old</p>`, (html) => `${html}<p>new</p>`, { variation: "mobile" });
469
+ expect(await diff.run()).to.equal("differs");
470
+ expect(pages.origins).to.deep.equal(["mobile https://shop.test/c/shoes"]);
471
+ expect(shown[0].left.label).to.equal("config at origin/main");
472
+ expect(shown[0].right.label).to.equal("working tree");
473
+ expect(removed).to.deep.equal(["base"]);
474
+ });
475
+ it("finds no diff when the change leaves the page alone", async () => {
476
+ const { diff } = baseService((html) => html, (html) => html);
477
+ expect(await diff.run()).to.equal("equal");
478
+ });
479
+ it("is uncacheable with the handler's message when the working tree throws", async () => {
480
+ const thrown = new PageSideFailure({
481
+ url: "https://shop.test/c/shoes",
482
+ variation: "default",
483
+ failure: documentHandlerFailure(new DocumentHandlerTransformError(new TypeError("grid is undefined"))),
484
+ });
485
+ const { diff, failed, log } = baseService((html) => html, () => thrown);
486
+ expect(await diff.run()).to.equal("uncacheable");
487
+ expect(failed).to.have.length(1);
488
+ expect(log.lines.join("\n")).to.contain("grid is undefined");
489
+ });
490
+ it("renders a saved page instead of requesting it", async () => {
491
+ const dir = mkdtempSync(path.join(tmpdir(), "sk-diff-spec-"));
492
+ const file = path.join(dir, "page.html");
493
+ writeFileSync(file, "<p>saved</p>");
494
+ const { diff, shown, pages } = baseService((html) => html, (html) => html, { html: file });
495
+ try {
496
+ expect(await diff.run()).to.equal("equal");
497
+ expect(pages.origins).to.have.length(0);
498
+ expect(shown[0].left.content).to.equal("<p>saved</p>");
499
+ }
500
+ finally {
501
+ rmSync(dir, { recursive: true });
502
+ }
503
+ });
504
+ });