@speedkit/cli 4.50.4 → 4.51.0-run-control.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 (416) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1369 -10
  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 +6 -1
  7. package/dist/commands/diff.js +9 -3
  8. package/dist/commands/onboarding/browser/click.d.ts +75 -0
  9. package/dist/commands/onboarding/browser/click.js +19 -0
  10. package/dist/commands/onboarding/browser/emulate.d.ts +93 -0
  11. package/dist/commands/onboarding/browser/emulate.js +23 -0
  12. package/dist/commands/onboarding/browser/navigate.d.ts +67 -0
  13. package/dist/commands/onboarding/browser/navigate.js +18 -0
  14. package/dist/commands/onboarding/browser/panel.d.ts +63 -0
  15. package/dist/commands/onboarding/browser/panel.js +12 -0
  16. package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
  17. package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
  18. package/dist/commands/onboarding/browser/reset.d.ts +71 -0
  19. package/dist/commands/onboarding/browser/reset.js +18 -0
  20. package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
  21. package/dist/commands/onboarding/browser/screenshot.js +19 -0
  22. package/dist/commands/onboarding/browser/state.d.ts +63 -0
  23. package/dist/commands/onboarding/browser/state.js +12 -0
  24. package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
  25. package/dist/commands/onboarding/browser/tabs.js +16 -0
  26. package/dist/commands/onboarding/cache/clear.d.ts +58 -0
  27. package/dist/commands/onboarding/cache/clear.js +12 -0
  28. package/dist/commands/onboarding/cache/errors.d.ts +58 -0
  29. package/dist/commands/onboarding/cache/errors.js +12 -0
  30. package/dist/commands/onboarding/cache/evict.d.ts +62 -0
  31. package/dist/commands/onboarding/cache/evict.js +15 -0
  32. package/dist/commands/onboarding/cache/get.d.ts +85 -0
  33. package/dist/commands/onboarding/cache/get.js +17 -0
  34. package/dist/commands/onboarding/cache/list.d.ts +58 -0
  35. package/dist/commands/onboarding/cache/list.js +15 -0
  36. package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
  37. package/dist/commands/onboarding/cache/prewarm.js +20 -0
  38. package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
  39. package/dist/commands/onboarding/cache/refresh.js +18 -0
  40. package/dist/commands/onboarding/cdp.d.ts +81 -0
  41. package/dist/commands/onboarding/cdp.js +18 -0
  42. package/dist/commands/onboarding/debug/arm.d.ts +77 -0
  43. package/dist/commands/onboarding/debug/arm.js +18 -0
  44. package/dist/commands/onboarding/debug/await.d.ts +71 -0
  45. package/dist/commands/onboarding/debug/await.js +18 -0
  46. package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
  47. package/dist/commands/onboarding/debug/disarm.js +12 -0
  48. package/dist/commands/onboarding/debug/eval.d.ts +75 -0
  49. package/dist/commands/onboarding/debug/eval.js +16 -0
  50. package/dist/commands/onboarding/debug/release.d.ts +63 -0
  51. package/dist/commands/onboarding/debug/release.js +12 -0
  52. package/dist/commands/onboarding/debug/resume.d.ts +63 -0
  53. package/dist/commands/onboarding/debug/resume.js +12 -0
  54. package/dist/commands/onboarding/debug/status.d.ts +63 -0
  55. package/dist/commands/onboarding/debug/status.js +12 -0
  56. package/dist/commands/onboarding/debug/step.d.ts +67 -0
  57. package/dist/commands/onboarding/debug/step.js +15 -0
  58. package/dist/commands/onboarding/files/list.d.ts +58 -0
  59. package/dist/commands/onboarding/files/list.js +12 -0
  60. package/dist/commands/onboarding/files/read.d.ts +73 -0
  61. package/dist/commands/onboarding/files/read.js +16 -0
  62. package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
  63. package/dist/commands/onboarding/files/rebuild.js +18 -0
  64. package/dist/commands/onboarding/files/validate.d.ts +58 -0
  65. package/dist/commands/onboarding/files/validate.js +12 -0
  66. package/dist/commands/onboarding/fouc.d.ts +77 -0
  67. package/dist/commands/onboarding/fouc.js +16 -0
  68. package/dist/commands/onboarding/inject/add.d.ts +89 -0
  69. package/dist/commands/onboarding/inject/add.js +17 -0
  70. package/dist/commands/onboarding/inject/clear.d.ts +63 -0
  71. package/dist/commands/onboarding/inject/clear.js +12 -0
  72. package/dist/commands/onboarding/inject/list.d.ts +63 -0
  73. package/dist/commands/onboarding/inject/list.js +12 -0
  74. package/dist/commands/onboarding/inject/read.d.ts +75 -0
  75. package/dist/commands/onboarding/inject/read.js +18 -0
  76. package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
  77. package/dist/commands/onboarding/inject/recipes.js +12 -0
  78. package/dist/commands/onboarding/inject/remove.d.ts +67 -0
  79. package/dist/commands/onboarding/inject/remove.js +15 -0
  80. package/dist/commands/onboarding/list.d.ts +13 -0
  81. package/dist/commands/onboarding/list.js +12 -0
  82. package/dist/commands/onboarding/logs.d.ts +41 -0
  83. package/dist/commands/onboarding/logs.js +256 -0
  84. package/dist/commands/onboarding/navwalk.d.ts +95 -0
  85. package/dist/commands/onboarding/navwalk.js +19 -0
  86. package/dist/commands/onboarding/response.d.ts +67 -0
  87. package/dist/commands/onboarding/response.js +18 -0
  88. package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
  89. package/dist/commands/onboarding/rum/beacons.js +16 -0
  90. package/dist/commands/onboarding/rum/get.d.ts +77 -0
  91. package/dist/commands/onboarding/rum/get.js +18 -0
  92. package/dist/commands/onboarding/rum/key.d.ts +67 -0
  93. package/dist/commands/onboarding/rum/key.js +13 -0
  94. package/dist/commands/onboarding/rum/previous.d.ts +63 -0
  95. package/dist/commands/onboarding/rum/previous.js +12 -0
  96. package/dist/commands/onboarding/status.d.ts +13 -0
  97. package/dist/commands/onboarding/status.js +17 -0
  98. package/dist/commands/onboarding/todo.d.ts +58 -0
  99. package/dist/commands/onboarding/todo.js +12 -0
  100. package/dist/commands/onboarding/viewport.d.ts +101 -0
  101. package/dist/commands/onboarding/viewport.js +18 -0
  102. package/dist/commands/onboarding/watch.d.ts +93 -0
  103. package/dist/commands/onboarding/watch.js +16 -0
  104. package/dist/commands/onboarding.d.ts +26 -0
  105. package/dist/commands/onboarding.js +220 -3
  106. package/dist/commands/origin-request.d.ts +4 -0
  107. package/dist/commands/origin-request.js +4 -0
  108. package/dist/commands/spec/onboarding.spec.d.ts +1 -0
  109. package/dist/commands/spec/onboarding.spec.js +127 -0
  110. package/dist/services/cli/build-info.d.ts +33 -0
  111. package/dist/services/cli/build-info.js +63 -0
  112. package/dist/services/cli/cli-environment-factory.d.ts +3 -0
  113. package/dist/services/cli/cli-environment-factory.js +1 -0
  114. package/dist/services/cli/cli-service-build-context.d.ts +3 -0
  115. package/dist/services/cli/cli-service-factory.js +1 -1
  116. package/dist/services/cli/cli-service-model.d.ts +29 -10
  117. package/dist/services/cli/cli-service.d.ts +60 -11
  118. package/dist/services/cli/cli-service.js +196 -32
  119. package/dist/services/cli/index.d.ts +2 -0
  120. package/dist/services/cli/index.js +2 -0
  121. package/dist/services/cli/sink.d.ts +47 -0
  122. package/dist/services/cli/sink.js +31 -0
  123. package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
  124. package/dist/services/cli/spec/build-identity.spec.js +85 -0
  125. package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
  126. package/dist/services/cli/spec/build-info.spec.js +10 -0
  127. package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
  128. package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
  129. package/dist/services/cli/spec/cli-service.spec.js +113 -50
  130. package/dist/services/cli/spec/memory-cli.d.ts +9 -0
  131. package/dist/services/cli/spec/memory-cli.js +9 -0
  132. package/dist/services/diff/config-at-ref.d.ts +20 -0
  133. package/dist/services/diff/config-at-ref.js +33 -0
  134. package/dist/services/diff/diff-service-build-context.d.ts +8 -0
  135. package/dist/services/diff/diff-service-build-context.js +40 -1
  136. package/dist/services/diff/diff-service-factory.d.ts +2 -0
  137. package/dist/services/diff/diff-service-factory.js +48 -20
  138. package/dist/services/diff/diff-service.d.ts +11 -0
  139. package/dist/services/diff/diff-service.js +37 -11
  140. package/dist/services/diff/page-source.d.ts +12 -0
  141. package/dist/services/diff/page-source.js +16 -11
  142. package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
  143. package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
  144. package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
  145. package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
  146. package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
  147. package/dist/services/diff/spec/diff-service.spec.js +95 -0
  148. package/dist/services/git/git-repository.d.ts +2 -0
  149. package/dist/services/git/git-repository.js +6 -0
  150. package/dist/services/integration-api/customer-config-flags.js +1 -0
  151. package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
  152. package/dist/services/onboarding/browser/baqend-response.js +23 -0
  153. package/dist/services/onboarding/browser/console-log.d.ts +9 -0
  154. package/dist/services/onboarding/browser/console-log.js +27 -0
  155. package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
  156. package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
  157. package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
  158. package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
  159. package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
  160. package/dist/services/onboarding/control/body-inspect.js +106 -0
  161. package/dist/services/onboarding/control/browser-session.d.ts +521 -0
  162. package/dist/services/onboarding/control/browser-session.js +1273 -0
  163. package/dist/services/onboarding/control/config-validation.d.ts +17 -0
  164. package/dist/services/onboarding/control/config-validation.js +46 -0
  165. package/dist/services/onboarding/control/control-protocol.d.ts +1390 -0
  166. package/dist/services/onboarding/control/control-protocol.js +69 -0
  167. package/dist/services/onboarding/control/control-server.d.ts +284 -0
  168. package/dist/services/onboarding/control/control-server.js +1609 -0
  169. package/dist/services/onboarding/control/debug-session.d.ts +190 -0
  170. package/dist/services/onboarding/control/debug-session.js +801 -0
  171. package/dist/services/onboarding/control/fouc.d.ts +23 -0
  172. package/dist/services/onboarding/control/fouc.js +151 -0
  173. package/dist/services/onboarding/control/index.d.ts +4 -0
  174. package/dist/services/onboarding/control/index.js +4 -0
  175. package/dist/services/onboarding/control/navwalk.d.ts +65 -0
  176. package/dist/services/onboarding/control/navwalk.js +248 -0
  177. package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
  178. package/dist/services/onboarding/control/preload-registry.js +829 -0
  179. package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
  180. package/dist/services/onboarding/control/response-explainer.js +257 -0
  181. package/dist/services/onboarding/control/rum.d.ts +8 -0
  182. package/dist/services/onboarding/control/rum.js +220 -0
  183. package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
  184. package/dist/services/onboarding/control/service-worker-tracker.js +119 -0
  185. package/dist/services/onboarding/control/viewport.d.ts +45 -0
  186. package/dist/services/onboarding/control/viewport.js +344 -0
  187. package/dist/services/onboarding/control/watch.d.ts +26 -0
  188. package/dist/services/onboarding/control/watch.js +149 -0
  189. package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
  190. package/dist/services/onboarding/dashboard/index.js +7 -2
  191. package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
  192. package/dist/services/onboarding/fetch-event-handler.js +94 -32
  193. package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +4 -25
  194. package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
  195. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
  196. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
  197. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
  198. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
  199. package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
  200. package/dist/services/onboarding/file-events/file-watcher.js +117 -12
  201. package/dist/services/onboarding/html-charset.d.ts +28 -0
  202. package/dist/services/onboarding/html-charset.js +57 -0
  203. package/dist/services/onboarding/onboarding-model.d.ts +30 -1
  204. package/dist/services/onboarding/onboarding-model.js +10 -1
  205. package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
  206. package/dist/services/onboarding/onboarding-service-build-context.js +6 -0
  207. package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
  208. package/dist/services/onboarding/onboarding-service-factory.js +131 -17
  209. package/dist/services/onboarding/onboarding-service.d.ts +40 -1
  210. package/dist/services/onboarding/onboarding-service.js +135 -22
  211. package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
  212. package/dist/services/onboarding/request-cache/asset-key.js +115 -0
  213. package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
  214. package/dist/services/onboarding/request-cache/cache.js +128 -17
  215. package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
  216. package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
  217. package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
  218. package/dist/services/onboarding/spec/control/browser-session.spec.js +526 -0
  219. package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
  220. package/dist/services/onboarding/spec/control/control-server.spec.js +338 -0
  221. package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
  222. package/dist/services/onboarding/spec/control/debug-session.spec.js +693 -0
  223. package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
  224. package/dist/services/onboarding/spec/control/fakes.js +66 -0
  225. package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
  226. package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
  227. package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
  228. package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
  229. package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
  230. package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
  231. package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
  232. package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
  233. package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
  234. package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
  235. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
  236. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
  237. package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
  238. package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
  239. package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
  240. package/dist/services/onboarding/spec/control/watch.spec.js +172 -0
  241. package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
  242. package/dist/services/onboarding/spec/fetch-event-handler.spec.js +202 -0
  243. package/dist/services/onboarding/spec/fetch-events/customer-domain-document-response.spec.d.ts +1 -0
  244. package/dist/services/onboarding/spec/fetch-events/customer-domain-document-response.spec.js +39 -0
  245. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
  246. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
  247. package/dist/services/onboarding/spec/html-charset.spec.d.ts +1 -0
  248. package/dist/services/onboarding/spec/html-charset.spec.js +58 -0
  249. package/dist/services/onboarding/spec/onboarding-model.spec.js +37 -0
  250. package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +1 -0
  251. package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
  252. package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
  253. package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
  254. package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
  255. package/dist/services/onboarding/spec/virtual-orestes-app/index.spec.d.ts +1 -0
  256. package/dist/services/onboarding/spec/virtual-orestes-app/index.spec.js +19 -0
  257. package/dist/services/onboarding/todo-collector.d.ts +7 -2
  258. package/dist/services/onboarding/todo-collector.js +49 -12
  259. package/dist/services/onboarding/virtual-orestes-app/index.d.ts +34 -0
  260. package/dist/services/onboarding/virtual-orestes-app/index.js +85 -53
  261. package/dist/services/origin-request/asset-variations.d.ts +14 -0
  262. package/dist/services/origin-request/asset-variations.js +11 -4
  263. package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
  264. package/dist/services/origin-request/origin-fetcher.js +43 -5
  265. package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
  266. package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
  267. package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
  268. package/dist/services/origin-request/origin-request-service-factory.js +2 -30
  269. package/dist/services/origin-request/origin-request-service.d.ts +121 -6
  270. package/dist/services/origin-request/origin-request-service.js +273 -49
  271. package/dist/services/origin-request/runtime-config-source.js +9 -4
  272. package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
  273. package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
  274. package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
  275. package/dist/services/query-builder/rules/rule-match.js +70 -0
  276. package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
  277. package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
  278. package/dist/services/run-control/browser/run-browser-contexts.d.ts +541 -0
  279. package/dist/services/run-control/browser/run-browser-contexts.js +78 -0
  280. package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
  281. package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
  282. package/dist/services/run-control/browser/run-browser-service.d.ts +64 -0
  283. package/dist/services/run-control/browser/run-browser-service.js +199 -0
  284. package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
  285. package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
  286. package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
  287. package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
  288. package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
  289. package/dist/services/run-control/cache/run-cache-service.js +151 -0
  290. package/dist/services/run-control/control-client.d.ts +36 -0
  291. package/dist/services/run-control/control-client.js +147 -0
  292. package/dist/services/run-control/debug/run-debug-contexts.d.ts +411 -0
  293. package/dist/services/run-control/debug/run-debug-contexts.js +44 -0
  294. package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
  295. package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
  296. package/dist/services/run-control/debug/run-debug-service.d.ts +38 -0
  297. package/dist/services/run-control/debug/run-debug-service.js +161 -0
  298. package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
  299. package/dist/services/run-control/files/run-files-contexts.js +26 -0
  300. package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
  301. package/dist/services/run-control/files/run-files-service-factory.js +7 -0
  302. package/dist/services/run-control/files/run-files-service.d.ts +29 -0
  303. package/dist/services/run-control/files/run-files-service.js +120 -0
  304. package/dist/services/run-control/index.d.ts +32 -0
  305. package/dist/services/run-control/index.js +31 -0
  306. package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
  307. package/dist/services/run-control/inject/run-inject-contexts.js +32 -0
  308. package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
  309. package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
  310. package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
  311. package/dist/services/run-control/inject/run-inject-service.js +203 -0
  312. package/dist/services/run-control/live-run.d.ts +37 -0
  313. package/dist/services/run-control/live-run.js +56 -0
  314. package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
  315. package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
  316. package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
  317. package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
  318. package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
  319. package/dist/services/run-control/probe/run-probe-service.js +193 -0
  320. package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
  321. package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
  322. package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
  323. package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
  324. package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
  325. package/dist/services/run-control/rum/run-rum-service.js +122 -0
  326. package/dist/services/run-control/run-answer.d.ts +28 -0
  327. package/dist/services/run-control/run-answer.js +58 -0
  328. package/dist/services/run-control/run-control-context.d.ts +102 -0
  329. package/dist/services/run-control/run-control-context.js +36 -0
  330. package/dist/services/run-control/run-control-flags.d.ts +12 -0
  331. package/dist/services/run-control/run-control-flags.js +22 -0
  332. package/dist/services/run-control/run-control-model.d.ts +9 -0
  333. package/dist/services/run-control/run-control-model.js +1 -0
  334. package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
  335. package/dist/services/run-control/run-control-service-factory.js +26 -0
  336. package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
  337. package/dist/services/run-control/session/run-session-contexts.js +20 -0
  338. package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
  339. package/dist/services/run-control/session/run-session-service-factory.js +18 -0
  340. package/dist/services/run-control/session/run-session-service.d.ts +25 -0
  341. package/dist/services/run-control/session/run-session-service.js +95 -0
  342. package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
  343. package/dist/services/run-control/spec/browser/run-browser-service.spec.js +327 -0
  344. package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
  345. package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
  346. package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
  347. package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
  348. package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
  349. package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
  350. package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
  351. package/dist/services/run-control/spec/inject/run-inject-service.spec.js +224 -0
  352. package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
  353. package/dist/services/run-control/spec/live-run-fixture.js +109 -0
  354. package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
  355. package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
  356. package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
  357. package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
  358. package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
  359. package/dist/services/run-control/spec/run-answer.spec.js +57 -0
  360. package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
  361. package/dist/services/run-control/spec/session/run-session-service.spec.js +101 -0
  362. package/dist/services/run-log/crash-mirror.d.ts +31 -0
  363. package/dist/services/run-log/crash-mirror.js +69 -0
  364. package/dist/services/run-log/index.d.ts +11 -0
  365. package/dist/services/run-log/index.js +11 -0
  366. package/dist/services/run-log/jsonl-appender.d.ts +46 -0
  367. package/dist/services/run-log/jsonl-appender.js +91 -0
  368. package/dist/services/run-log/log-event-model.d.ts +104 -0
  369. package/dist/services/run-log/log-event-model.js +56 -0
  370. package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
  371. package/dist/services/run-log/log-query-service-factory.js +14 -0
  372. package/dist/services/run-log/log-query-service.d.ts +59 -0
  373. package/dist/services/run-log/log-query-service.js +111 -0
  374. package/dist/services/run-log/log-reader.d.ts +84 -0
  375. package/dist/services/run-log/log-reader.js +180 -0
  376. package/dist/services/run-log/log-summary.d.ts +72 -0
  377. package/dist/services/run-log/log-summary.js +208 -0
  378. package/dist/services/run-log/redaction.d.ts +34 -0
  379. package/dist/services/run-log/redaction.js +124 -0
  380. package/dist/services/run-log/request-log.d.ts +80 -0
  381. package/dist/services/run-log/request-log.js +69 -0
  382. package/dist/services/run-log/request-summary.d.ts +76 -0
  383. package/dist/services/run-log/request-summary.js +0 -0
  384. package/dist/services/run-log/run-log.d.ts +61 -0
  385. package/dist/services/run-log/run-log.js +102 -0
  386. package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
  387. package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
  388. package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
  389. package/dist/services/run-log/spec/log-reader.spec.js +109 -0
  390. package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
  391. package/dist/services/run-log/spec/log-summary.spec.js +153 -0
  392. package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
  393. package/dist/services/run-log/spec/redaction.spec.js +61 -0
  394. package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
  395. package/dist/services/run-log/spec/request-log.spec.js +101 -0
  396. package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
  397. package/dist/services/run-log/spec/request-summary.spec.js +171 -0
  398. package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
  399. package/dist/services/run-log/spec/run-log.spec.js +122 -0
  400. package/dist/services/run-registry/exit-classification.d.ts +39 -0
  401. package/dist/services/run-registry/exit-classification.js +42 -0
  402. package/dist/services/run-registry/index.d.ts +3 -0
  403. package/dist/services/run-registry/index.js +3 -0
  404. package/dist/services/run-registry/process-identity.d.ts +28 -0
  405. package/dist/services/run-registry/process-identity.js +80 -0
  406. package/dist/services/run-registry/run-registry-model.d.ts +128 -0
  407. package/dist/services/run-registry/run-registry-model.js +16 -0
  408. package/dist/services/run-registry/run-registry.d.ts +150 -0
  409. package/dist/services/run-registry/run-registry.js +409 -0
  410. package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
  411. package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
  412. package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
  413. package/dist/services/run-registry/spec/run-registry.spec.js +509 -0
  414. package/dist/services/setup/os/tool-registry.js +2 -2
  415. package/oclif.manifest.json +3293 -272
  416. package/package.json +21 -3
@@ -0,0 +1,85 @@
1
+ import { expect } from "chai";
2
+ import { describe, it } from "mocha";
3
+ import { execFileSync } from "node:child_process";
4
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
5
+ import { resolve } from "node:path";
6
+ /**
7
+ * The guard for "this process knows which build it is".
8
+ *
9
+ * `sk onboarding` runs for hours, and `dist/` is replaced underneath it by
10
+ * every rebuild. The stamp used to be read lazily on first call, which meant a
11
+ * long-lived process reported whatever was on disk the moment something first
12
+ * asked — a process started at 08:02 named a commit made at 12:40, with
13
+ * `dirty: false` to make it look trustworthy. A run's `meta.json` records that
14
+ * commit, so the opposite of what the field is for.
15
+ *
16
+ * Run in a child process against the built module, because the bug only exists
17
+ * across a rebuild: it cannot be reproduced by calling a function twice in one
18
+ * process unless that process loaded the module before the file changed.
19
+ * `npm test` skips it without a build, the way the stdio guard does.
20
+ */
21
+ describe("build identity across a rebuild", () => {
22
+ const stamp = resolve("dist/build-info.json");
23
+ const module = resolve("dist/services/cli/build-info.js");
24
+ /**
25
+ * Import the built module, rewrite the stamp, and only *then* ask.
26
+ *
27
+ * The order is the test. Calling `buildInfo()` before the rewrite caches the
28
+ * right answer and the bug disappears — which is exactly what the first
29
+ * version of this spec did, and it passed against the broken implementation.
30
+ * A lazily-read stamp is only wrong when the first call lands after the
31
+ * rebuild, which is the real case: a process started at 08:02 that is first
32
+ * asked something at 13:00.
33
+ */
34
+ function askAfterRebuild(rewrite) {
35
+ const script = `
36
+ import { writeFileSync } from "node:fs";
37
+ // Imported here, asked below. Nothing may call buildInfo() in between.
38
+ import { buildInfo } from ${JSON.stringify(module)};
39
+
40
+ if (${rewrite}) {
41
+ writeFileSync(${JSON.stringify(stamp)}, JSON.stringify({
42
+ commit: "deadbeef",
43
+ dirty: false,
44
+ buildId: "ffffffffffff",
45
+ builtAt: new Date().toISOString(),
46
+ }));
47
+ }
48
+
49
+ process.stdout.write(JSON.stringify({
50
+ reported: { ...buildInfo() },
51
+ }));
52
+ `;
53
+ return JSON.parse(execFileSync(process.execPath, ["--input-type=module", "-e", script], {
54
+ encoding: "utf8",
55
+ }));
56
+ }
57
+ it("should keep naming the build it loaded, not the one on disk", function () {
58
+ if (!existsSync(module) || !existsSync(stamp)) {
59
+ this.skip();
60
+ }
61
+ const original = readFileSync(stamp, "utf8");
62
+ const loaded = JSON.parse(original).buildId;
63
+ try {
64
+ const result = askAfterRebuild(true);
65
+ // The assertion the lazy implementation fails: asked for the first time
66
+ // after the rebuild, it reported the build it had never loaded.
67
+ expect(result.reported.buildId).to.equal(loaded);
68
+ expect(result.reported.buildId).to.not.equal("ffffffffffff");
69
+ expect(result.reported.commit).to.not.equal("deadbeef");
70
+ }
71
+ finally {
72
+ writeFileSync(stamp, original);
73
+ }
74
+ });
75
+ it("should restore the stamp it borrowed", function () {
76
+ if (!existsSync(stamp)) {
77
+ this.skip();
78
+ }
79
+ // The case above rewrites a real file in `dist/`. If it leaves it
80
+ // wrong, every later answer about this build is wrong too — so it is worth
81
+ // one assertion rather than trust.
82
+ const current = JSON.parse(readFileSync(stamp, "utf8"));
83
+ expect(current.buildId).to.not.equal("ffffffffffff");
84
+ });
85
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { expect } from "chai";
2
+ import { describe, it } from "mocha";
3
+ import { buildLabel } from "../build-info.js";
4
+ describe("buildLabel", () => {
5
+ it("should name a build even where the stamp is missing", () => {
6
+ // A tarball install has no git and a build predating the stamp has no
7
+ // file. Reporting the bare version is honest; inventing a commit is not.
8
+ expect(buildLabel("4.28.0")).to.be.a("string").and.contain("4.28.0");
9
+ });
10
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,133 @@
1
+ import { expect } from "chai";
2
+ import { afterEach, beforeEach, describe, it } from "mocha";
3
+ import { MemorySink } from "../sink.js";
4
+ import { MemoryRunLog } from "../../run-log/index.js";
5
+ import { memoryCli } from "./memory-cli.js";
6
+ describe("CliService writing to a run log", () => {
7
+ let ci;
8
+ let sink;
9
+ let log;
10
+ let cli;
11
+ beforeEach(() => {
12
+ ci = process.env.CI;
13
+ process.env.CI = "true";
14
+ sink = new MemorySink();
15
+ log = new MemoryRunLog();
16
+ cli = memoryCli(sink);
17
+ cli.attachLog(log);
18
+ });
19
+ afterEach(() => {
20
+ if (ci === undefined) {
21
+ delete process.env.CI;
22
+ return;
23
+ }
24
+ process.env.CI = ci;
25
+ });
26
+ it("records nothing before a log is attached", () => {
27
+ const detached = memoryCli();
28
+ expect(() => detached.write("no log here")).to.not.throw();
29
+ });
30
+ it("gives each write the level its method implies", () => {
31
+ cli.write("plain");
32
+ cli.writeSuccess("done");
33
+ cli.writeWarning("careful");
34
+ cli.writeError("broken");
35
+ expect(log.events.map((event) => [event.level, event.msg])).to.eql([
36
+ ["info", "plain"],
37
+ ["success", "done"],
38
+ ["warn", "careful"],
39
+ ["error", "broken"],
40
+ ]);
41
+ });
42
+ it("records a warning once, not once as a warning and once as a write", () => {
43
+ // `writeWarning` used to delegate to `write`, which would log the same line
44
+ // twice — the second time at the wrong level.
45
+ cli.writeWarning("careful");
46
+ expect(log.events).to.have.length(1);
47
+ expect(sink.lines).to.have.length(1);
48
+ });
49
+ it("carries the scope and data the caller annotated", () => {
50
+ cli.write("served from origin", false, {
51
+ scope: "fetch",
52
+ data: { url: "/checkout", responseCause: "SwBooting" },
53
+ });
54
+ expect(log.events[0].scope).to.equal("fetch");
55
+ expect(log.events[0].data).to.eql({
56
+ url: "/checkout",
57
+ responseCause: "SwBooting",
58
+ });
59
+ });
60
+ it("lets a caller overrule the level its method implies", () => {
61
+ cli.writeWarning("this one is routine", false, { level: "debug" });
62
+ expect(log.events[0].level).to.equal("debug");
63
+ });
64
+ it("records a buffered line when it is buffered, with its own level", () => {
65
+ // Buffered lines are flushed as one block. Logging at flush time would
66
+ // report a page of mixed warnings and successes as a single info line.
67
+ cli.writeWarning("careful", true);
68
+ cli.writeSuccess("done", true);
69
+ cli.writeBuffer();
70
+ expect(log.events.map((event) => event.level)).to.eql(["warn", "success"]);
71
+ });
72
+ it("records an action's whole lifecycle", () => {
73
+ cli.startAction("INSTALL", "install Speed Kit");
74
+ cli.failAction("INSTALL", "could not reach the origin");
75
+ expect(log.events.map((event) => [event.action?.state, event.level])).to.eql([
76
+ ["start", "info"],
77
+ ["fail", "error"],
78
+ ]);
79
+ });
80
+ it("names the action it ended, even when the caller did not", () => {
81
+ cli.startAction("WARM", "warm the list");
82
+ cli.successAction("WARM");
83
+ expect(log.events[1].msg).to.equal("warm the list");
84
+ });
85
+ it("records what a quiet run would have printed", () => {
86
+ // The log is not the terminal. A `--quiet` session prints nothing and still
87
+ // happened, and an empty log would be the most misleading file in the run
88
+ // directory.
89
+ const quiet = memoryCli(sink, true);
90
+ quiet.attachLog(log);
91
+ quiet.startAction("BUILD", "build the bundle");
92
+ expect(log.events).to.have.length(1);
93
+ });
94
+ it("records a question before the answer exists, and again after", async () => {
95
+ const quiet = memoryCli(sink, true);
96
+ quiet.attachLog(log);
97
+ // Under `--quiet` the default is taken without asking, so the pair here is
98
+ // one event: there was never a question on screen to record as pending.
99
+ await quiet.confirm("Start anyway?", false);
100
+ expect(log.events).to.have.length(1);
101
+ expect(log.events[0].interaction).to.include({
102
+ kind: "confirm",
103
+ question: "Start anyway?",
104
+ answer: false,
105
+ defaulted: true,
106
+ });
107
+ });
108
+ it("withholds the answer to a prompt the caller marked sensitive", async () => {
109
+ const quiet = memoryCli(sink, true);
110
+ quiet.attachLog(log);
111
+ await quiet.prompt("Basic auth password", {
112
+ defaultAnswer: "hunter2",
113
+ sensitive: true,
114
+ });
115
+ expect(log.events[0].interaction?.sensitive).to.equal(true);
116
+ expect(log.events[0].interaction?.answer).to.equal(undefined);
117
+ // The question itself is the useful part, and it is not the secret.
118
+ expect(log.events[0].interaction?.question).to.equal("Basic auth password");
119
+ });
120
+ it("records a table as rows, not as the rendered grid", () => {
121
+ cli.table([{ url: "/a", hits: 2 }], { url: {}, hits: {} });
122
+ expect(log.events[0].data).to.eql({
123
+ columns: ["url", "hits"],
124
+ rows: [{ url: "/a", hits: 2 }],
125
+ });
126
+ });
127
+ it("records that a payload was written, without its bytes", () => {
128
+ cli.pipe("SELECT * FROM rum.pi\n");
129
+ expect(log.events[0].level).to.equal("debug");
130
+ expect(log.events[0].msg).to.contain("bytes");
131
+ expect(log.events[0].msg).to.not.contain("SELECT");
132
+ });
133
+ });
@@ -1,58 +1,67 @@
1
1
  import { expect } from "chai";
2
2
  import { afterEach, beforeEach, describe, it } from "mocha";
3
- import { CliService } from "../cli-service.js";
4
- import { ClipboardService } from "../clipboard/index.js";
5
- /** What a CI runner looks like to the CLI: no spinner can spin, nobody to ask. */
6
- const CI_TERMINAL = { isCI: true, nonInteractive: true };
7
- /** The lines a block of work put on stdout. */
8
- function captured(work) {
9
- const lines = [];
10
- const log = console.log;
11
- console.log = (line) => lines.push(line);
12
- try {
13
- work();
14
- }
15
- finally {
16
- console.log = log;
17
- }
18
- return lines;
19
- }
3
+ import { MemorySink } from "../sink.js";
4
+ import { memoryCli } from "./memory-cli.js";
20
5
  describe("CliService actions without a terminal", () => {
6
+ let sink;
7
+ beforeEach(() => {
8
+ sink = new MemorySink();
9
+ });
21
10
  it("should say nothing while an action runs", () => {
22
- const cli = new CliService(new ClipboardService(), CI_TERMINAL);
23
- expect(captured(() => cli.startAction("BUILD", "build prewarm-query"))).to.have.lengthOf(0);
11
+ const cli = memoryCli(sink);
12
+ cli.startAction("BUILD", "build prewarm-query");
13
+ expect(sink.lines).to.have.lengthOf(0);
24
14
  });
25
15
  it("should log an action that ended exactly once", () => {
26
16
  // Spinnies re-renders every spinner it knows on each update when it cannot
27
17
  // animate, so a running action reappears under each later one — a job with
28
18
  // four actions logged "build prewarm-query" four times.
29
- const cli = new CliService(new ClipboardService(), CI_TERMINAL);
30
- const lines = captured(() => {
31
- cli.startAction("BUILD", "build prewarm-query");
32
- cli.successAction("BUILD");
33
- cli.startAction("QUERY", "execute athena query");
34
- cli.failAction("QUERY");
35
- });
36
- expect(lines).to.have.lengthOf(2);
37
- expect(lines[0]).to.contain("build prewarm-query");
38
- expect(lines[1]).to.contain("execute athena query");
39
- expect(lines.join("\n")).to.not.contain("build prewarm-query\n✖ execute athena query\n✔ build prewarm-query");
19
+ const cli = memoryCli(sink);
20
+ cli.startAction("BUILD", "build prewarm-query");
21
+ cli.successAction("BUILD");
22
+ cli.startAction("QUERY", "execute athena query");
23
+ cli.failAction("QUERY");
24
+ expect(sink.lines).to.have.lengthOf(2);
25
+ expect(sink.lines[0]).to.contain("build prewarm-query");
26
+ expect(sink.lines[1]).to.contain("execute athena query");
27
+ expect(sink.lines.join("\n")).to.not.contain("build prewarm-query\n✖ execute athena query\n✔ build prewarm-query");
40
28
  });
41
29
  it("should keep the text of the action it ends", () => {
42
- const cli = new CliService(new ClipboardService(), CI_TERMINAL);
43
- const lines = captured(() => {
44
- cli.startAction("WARM", "warm the list");
45
- cli.endAction("WARM");
46
- });
47
- expect(lines).to.deep.equal(["- warm the list"]);
30
+ const cli = memoryCli(sink);
31
+ cli.startAction("WARM", "warm the list");
32
+ cli.endAction("WARM");
33
+ expect(sink.lines).to.deep.equal(["- warm the list"]);
48
34
  });
49
35
  it("should stay silent when it was told to be quiet", () => {
50
- const cli = new CliService(new ClipboardService(), CI_TERMINAL, true);
51
- const lines = captured(() => {
52
- cli.startAction("BUILD", "build prewarm-query");
53
- cli.successAction("BUILD");
54
- });
55
- expect(lines).to.have.lengthOf(0);
36
+ const cli = memoryCli(sink, true);
37
+ cli.startAction("BUILD", "build prewarm-query");
38
+ cli.successAction("BUILD");
39
+ expect(sink.lines).to.have.lengthOf(0);
40
+ });
41
+ });
42
+ describe("CliService channels", () => {
43
+ it("should keep a payload off the line channel and asides off both", () => {
44
+ const sink = new MemorySink();
45
+ const cli = memoryCli(sink);
46
+ cli.write("a human line");
47
+ cli.pipe("SELECT 1");
48
+ cli.note("2 rules were reduced");
49
+ expect(sink.lines).to.deep.equal(["a human line"]);
50
+ expect(sink.payloads).to.deep.equal(["SELECT 1"]);
51
+ expect(sink.asides).to.deep.equal(["2 rules were reduced"]);
52
+ });
53
+ it("should not add a newline to a payload", () => {
54
+ const sink = new MemorySink();
55
+ const cli = memoryCli(sink);
56
+ cli.pipe("a\tb\n");
57
+ cli.pipe("c");
58
+ expect(sink.payloads.join("")).to.equal("a\tb\nc");
59
+ });
60
+ it("should write a payload even when quiet, because quiet is what asks for it", () => {
61
+ const sink = new MemorySink();
62
+ const cli = memoryCli(sink, true);
63
+ cli.pipe("SELECT 1");
64
+ expect(sink.payloads).to.deep.equal(["SELECT 1"]);
56
65
  });
57
66
  });
58
67
  describe("CliService table", () => {
@@ -76,23 +85,77 @@ describe("CliService table", () => {
76
85
  outcome: "alreadyDeployed",
77
86
  reason: "commits after !8021 change config_documentHandler.js and config_dynamicStyles.css of this customer",
78
87
  };
79
- it("keeps the short columns readable and wraps the long one", () => {
80
- const lines = captured(() => new CliService(new ClipboardService(), CI_TERMINAL).table([row], {
88
+ /** The lines the table put out, the row above as its only row. */
89
+ function tabled() {
90
+ const sink = new MemorySink();
91
+ memoryCli(sink).table([row], {
81
92
  customer: {},
82
93
  outcome: {},
83
94
  reason: {},
84
- }));
95
+ });
96
+ return sink.lines;
97
+ }
98
+ it("keeps the short columns readable and wraps the long one", () => {
99
+ const lines = tabled();
85
100
  expect(lines.join("\n")).to.contain("carhartt-wip-new");
86
101
  expect(lines.join("\n")).to.contain("alreadyDeployed");
87
102
  });
88
103
  it("stays inside the terminal", () => {
89
- const lines = captured(() => new CliService(new ClipboardService(), CI_TERMINAL).table([row], {
90
- customer: {},
91
- outcome: {},
92
- reason: {},
93
- }));
104
+ const lines = tabled();
94
105
  for (const line of lines.join("\n").split("\n")) {
95
106
  expect(line.length, line).to.be.at.most(80);
96
107
  }
97
108
  });
98
109
  });
110
+ describe("CliService and the SIGINT listener", () => {
111
+ let saved;
112
+ beforeEach(() => {
113
+ // Start from a known-clean slate. Without this a listener spinnies left
114
+ // behind in an earlier case makes the count assertions pass by accident.
115
+ saved = process.rawListeners("SIGINT");
116
+ for (const listener of saved) {
117
+ process.off("SIGINT", listener);
118
+ }
119
+ });
120
+ afterEach(() => {
121
+ for (const listener of process.rawListeners("SIGINT")) {
122
+ process.off("SIGINT", listener);
123
+ }
124
+ for (const listener of saved) {
125
+ process.on("SIGINT", listener);
126
+ }
127
+ });
128
+ it("should leave a handler registered before it alone", () => {
129
+ // Spinnies' constructor calls process.removeAllListeners("SIGINT") and
130
+ // installs one that process.exit(0)s. `sk onboarding` registers its
131
+ // shutdown handler before the browser launches, so constructing a
132
+ // CliService used to delete it — silently, and three test sessions blamed
133
+ // the CLI's own handler for the result.
134
+ const ours = () => undefined;
135
+ process.on("SIGINT", ours);
136
+ try {
137
+ memoryCli();
138
+ expect(process.listeners("SIGINT")).to.contain(ours);
139
+ }
140
+ finally {
141
+ process.off("SIGINT", ours);
142
+ }
143
+ });
144
+ it("should not leave a listener of its own behind", () => {
145
+ memoryCli();
146
+ // Spinnies' handler would otherwise exit(0) on Ctrl+C, skipping every
147
+ // shutdown the CLI owns. The cursor it restored is restoreTerminal's job.
148
+ expect(process.listeners("SIGINT")).to.have.lengthOf(0);
149
+ });
150
+ it("should keep a once-registration a once-registration", () => {
151
+ const ours = () => undefined;
152
+ process.once("SIGINT", ours);
153
+ memoryCli();
154
+ // Deliberately asserted on the wrapper rather than by emitting a signal:
155
+ // if this regresses, the listener in place is spinnies' `process.exit(0)`,
156
+ // and emitting would take the test runner down with it instead of failing.
157
+ // Node marks a once-wrapper by hanging the original off `.listener`.
158
+ const [raw] = process.rawListeners("SIGINT");
159
+ expect(raw?.listener).to.equal(ours);
160
+ });
161
+ });
@@ -0,0 +1,9 @@
1
+ import { CliService } from "../cli-service.js";
2
+ import { MemorySink } from "../sink.js";
3
+ /** What a CI runner looks like to the CLI: no spinner can spin, nobody to ask. */
4
+ export declare const CI_TERMINAL: {
5
+ isCI: boolean;
6
+ nonInteractive: boolean;
7
+ };
8
+ /** A CLI on a CI runner that writes into `sink` rather than the terminal. */
9
+ export declare function memoryCli(sink?: MemorySink, quiet?: boolean): CliService;
@@ -0,0 +1,9 @@
1
+ import { CliService } from "../cli-service.js";
2
+ import { ClipboardService } from "../clipboard/index.js";
3
+ import { MemorySink } from "../sink.js";
4
+ /** What a CI runner looks like to the CLI: no spinner can spin, nobody to ask. */
5
+ export const CI_TERMINAL = { isCI: true, nonInteractive: true };
6
+ /** A CLI on a CI runner that writes into `sink` rather than the terminal. */
7
+ export function memoryCli(sink = new MemorySink(), quiet = false) {
8
+ return new CliService(new ClipboardService(), CI_TERMINAL, quiet, sink);
9
+ }
@@ -0,0 +1,20 @@
1
+ import { GitRepository } from "../git/index.js";
2
+ /** A customer directory as a git ref holds it, written to a temp directory. */
3
+ export interface ConfigAtRef {
4
+ /** The customer directory in the temp directory. */
5
+ readonly customerPath: string;
6
+ /** The commit the files come from: where HEAD left the ref. */
7
+ readonly commit: string;
8
+ /** Deletes the temp directory. */
9
+ remove(): Promise<void>;
10
+ }
11
+ /**
12
+ * Writes the customer directory as `ref` holds it to a temp directory, so
13
+ * the documentHandler can be built from it beside the working tree's.
14
+ * The files come from the merge base of HEAD and `ref`, so changes that
15
+ * landed on `ref` after the branch left it do not show up reversed.
16
+ *
17
+ * shortcut: files are read as utf8, so a binary file in the customer
18
+ * directory is mangled; read buffers when a config ships one.
19
+ */
20
+ export declare function configAtRef(customerPath: string, ref: string, repository?: GitRepository): Promise<ConfigAtRef>;
@@ -0,0 +1,33 @@
1
+ import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
2
+ import { tmpdir } from "node:os";
3
+ import path from "node:path";
4
+ import ApplicationError from "../error-handling/error/application-error.js";
5
+ import { GitRepository } from "../git/index.js";
6
+ /**
7
+ * Writes the customer directory as `ref` holds it to a temp directory, so
8
+ * the documentHandler can be built from it beside the working tree's.
9
+ * The files come from the merge base of HEAD and `ref`, so changes that
10
+ * landed on `ref` after the branch left it do not show up reversed.
11
+ *
12
+ * shortcut: files are read as utf8, so a binary file in the customer
13
+ * directory is mangled; read buffers when a config ships one.
14
+ */
15
+ export async function configAtRef(customerPath, ref, repository = GitRepository.at(customerPath)) {
16
+ const directory = repository.relative(customerPath);
17
+ const commit = repository.mergeBase(ref);
18
+ const files = repository.pathsAt(commit, directory);
19
+ if (files.length === 0) {
20
+ throw new ApplicationError(`no config at ${ref} (${commit.slice(0, 8)}) for ${directory}; use a ref that has one, or drop --base for a new customer.`);
21
+ }
22
+ const root = await mkdtemp(path.join(tmpdir(), "sk-diff-base-"));
23
+ for (const file of files) {
24
+ const target = path.join(root, file);
25
+ await mkdir(path.dirname(target), { recursive: true });
26
+ await writeFile(target, repository.contentAt(commit, file));
27
+ }
28
+ return {
29
+ customerPath: path.join(root, directory),
30
+ commit,
31
+ remove: () => rm(root, { recursive: true, force: true }),
32
+ };
33
+ }
@@ -11,6 +11,8 @@ declare const flags: {
11
11
  variations: Interfaces.OptionFlag<string[], Interfaces.CustomOptions>;
12
12
  against: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
13
13
  variation: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
14
+ base: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
15
+ html: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
14
16
  baseline: Interfaces.BooleanFlag<boolean>;
15
17
  params: Interfaces.BooleanFlag<boolean>;
16
18
  param: Interfaces.OptionFlag<string[], Interfaces.CustomOptions>;
@@ -46,6 +48,10 @@ export interface DiffOptions {
46
48
  readonly pageUrl: string;
47
49
  /** The page {@link pageUrl} is compared with, in place of the parameter check. */
48
50
  readonly against?: string;
51
+ /** The git ref whose customer config renders the page, against the working tree's. */
52
+ readonly base?: string;
53
+ /** With {@link base}: a saved origin page, rendered instead of a request. */
54
+ readonly html?: string;
49
55
  /** The variation `against` and a parameter check without `variations` request. */
50
56
  readonly variation: string;
51
57
  /** Ask which variation to request the pages in, in place of {@link variation}. */
@@ -87,6 +93,8 @@ export declare class DiffServiceBuildContext extends DiffServiceBuildContext_bas
87
93
  variations: Interfaces.OptionFlag<string[], Interfaces.CustomOptions>;
88
94
  against: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
89
95
  variation: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
96
+ base: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
97
+ html: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
90
98
  baseline: Interfaces.BooleanFlag<boolean>;
91
99
  params: Interfaces.BooleanFlag<boolean>;
92
100
  param: Interfaces.OptionFlag<string[], Interfaces.CustomOptions>;
@@ -38,7 +38,13 @@ const flags = {
38
38
  description: "Compare the page against this other page, both requested and rendered the same way: ?color=red against ?color=blue. Replaces the parameter check",
39
39
  }),
40
40
  variation: Flags.string({
41
- description: "The one variation the pages are requested in, for --against or the parameter check: mobile, tablet or a custom one; an empty one asks which. Defaults to desktop",
41
+ description: "The one variation the pages are requested in, for --against, --base or the parameter check: mobile, tablet or a custom one; an empty one asks which. Defaults to desktop",
42
+ }),
43
+ base: Flags.string({
44
+ description: "Render the page with the customer config where HEAD left this git ref (their merge base) and with the working tree, and diff the two: what a config change does to the page. Replaces the parameter check; takes --variation and --html",
45
+ }),
46
+ html: Flags.string({
47
+ description: "With --base, render this saved origin HTML instead of requesting the page",
42
48
  }),
43
49
  baseline: Flags.boolean({
44
50
  description: "Fetch every side twice and ignore what differs between the two, such as nonces, timestamps or reordered preloads. Doubles the requests: 4 per comparison",
@@ -129,6 +135,36 @@ function againstUrl(pageUrl, parsedFlags) {
129
135
  }
130
136
  return against;
131
137
  }
138
+ /**
139
+ * The git ref `--base` names. It compares two configs on one page, so it
140
+ * needs the customer and the documentHandler, and refuses the flags of the
141
+ * checks it replaces. `--html` only feeds it.
142
+ */
143
+ function baseRef(customerPath, parsedFlags) {
144
+ const { base, html } = parsedFlags;
145
+ if (base === undefined) {
146
+ if (html !== undefined) {
147
+ throw new ApplicationError("--html renders a saved page for --base.", [
148
+ "sk diff <customerPath> <pageUrl> --base origin/main --html page.html",
149
+ ]);
150
+ }
151
+ return undefined;
152
+ }
153
+ if (!customerPath || parsedFlags.raw) {
154
+ throw new ApplicationError("--base compares two configs of a customer, so it needs the customer path and the documentHandler.", ["sk diff <customerPath> <pageUrl> --base origin/main"]);
155
+ }
156
+ const conflicting = [
157
+ parsedFlags.against !== undefined && "--against",
158
+ parsedFlags.param !== undefined && "--param",
159
+ parsedFlags.params && "--params",
160
+ parsedFlags.variations !== undefined && "--variations",
161
+ parsedFlags.baseline && "--baseline",
162
+ ].filter(Boolean);
163
+ if (conflicting.length > 0) {
164
+ throw new ApplicationError(`--base renders one page with two configs, so it does not take ${conflicting.join(", ")}.`, ["For another variation than desktop, name one: --variation mobile"]);
165
+ }
166
+ return base;
167
+ }
132
168
  /**
133
169
  * The one variation `--variation` names, desktop by default, or before an
134
170
  * empty one is answered. `--variations` compares a pair, so the two are
@@ -268,6 +304,7 @@ export class DiffServiceBuildContext extends Context() {
268
304
  if (!customerPath && !parsedFlags.raw) {
269
305
  throw new ApplicationError("Without a customer path there is no documentHandler to render with.", ["Name the customer, or pass --raw to compare the origin's HTML."]);
270
306
  }
307
+ const base = baseRef(customerPath, parsedFlags);
271
308
  const against = againstUrl(pageUrl, parsedFlags);
272
309
  const variation = singleVariation(parsedFlags);
273
310
  const chooseVariation = choosesVariation(parsedFlags.variation, environment);
@@ -280,6 +317,8 @@ export class DiffServiceBuildContext extends Context() {
280
317
  configName: parsedFlags.configName,
281
318
  pageUrl,
282
319
  against,
320
+ base,
321
+ html: parsedFlags.html,
283
322
  variation,
284
323
  chooseVariation,
285
324
  variations: chooseVariations
@@ -6,6 +6,8 @@ export declare class DiffServiceFactory {
6
6
  constructor(context: DiffServiceBuildContext);
7
7
  buildService(): Promise<DiffService>;
8
8
  private build;
9
+ /** The pages rendered with the customer config at `--base`, from a checkout of it. */
10
+ private buildBase;
9
11
  /**
10
12
  * The options, with the parameters an empty `--param` asked for added to
11
13
  * the ones removed. Asked first, before anything is loaded or fetched.