@speedkit/cli 4.50.5 → 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.
- package/README.md +1369 -10
- package/dist/base/run-control-command.d.ts +15 -0
- package/dist/base/run-control-command.js +20 -0
- package/dist/build-info.json +6 -0
- package/dist/commands/diff.d.ts +6 -1
- package/dist/commands/diff.js +9 -3
- package/dist/commands/onboarding/browser/click.d.ts +75 -0
- package/dist/commands/onboarding/browser/click.js +19 -0
- package/dist/commands/onboarding/browser/emulate.d.ts +93 -0
- package/dist/commands/onboarding/browser/emulate.js +23 -0
- package/dist/commands/onboarding/browser/navigate.d.ts +67 -0
- package/dist/commands/onboarding/browser/navigate.js +18 -0
- package/dist/commands/onboarding/browser/panel.d.ts +63 -0
- package/dist/commands/onboarding/browser/panel.js +12 -0
- package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
- package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
- package/dist/commands/onboarding/browser/reset.d.ts +71 -0
- package/dist/commands/onboarding/browser/reset.js +18 -0
- package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
- package/dist/commands/onboarding/browser/screenshot.js +19 -0
- package/dist/commands/onboarding/browser/state.d.ts +63 -0
- package/dist/commands/onboarding/browser/state.js +12 -0
- package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
- package/dist/commands/onboarding/browser/tabs.js +16 -0
- package/dist/commands/onboarding/cache/clear.d.ts +58 -0
- package/dist/commands/onboarding/cache/clear.js +12 -0
- package/dist/commands/onboarding/cache/errors.d.ts +58 -0
- package/dist/commands/onboarding/cache/errors.js +12 -0
- package/dist/commands/onboarding/cache/evict.d.ts +62 -0
- package/dist/commands/onboarding/cache/evict.js +15 -0
- package/dist/commands/onboarding/cache/get.d.ts +85 -0
- package/dist/commands/onboarding/cache/get.js +17 -0
- package/dist/commands/onboarding/cache/list.d.ts +58 -0
- package/dist/commands/onboarding/cache/list.js +15 -0
- package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
- package/dist/commands/onboarding/cache/prewarm.js +20 -0
- package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
- package/dist/commands/onboarding/cache/refresh.js +18 -0
- package/dist/commands/onboarding/cdp.d.ts +81 -0
- package/dist/commands/onboarding/cdp.js +18 -0
- package/dist/commands/onboarding/debug/arm.d.ts +77 -0
- package/dist/commands/onboarding/debug/arm.js +18 -0
- package/dist/commands/onboarding/debug/await.d.ts +71 -0
- package/dist/commands/onboarding/debug/await.js +18 -0
- package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
- package/dist/commands/onboarding/debug/disarm.js +12 -0
- package/dist/commands/onboarding/debug/eval.d.ts +75 -0
- package/dist/commands/onboarding/debug/eval.js +16 -0
- package/dist/commands/onboarding/debug/release.d.ts +63 -0
- package/dist/commands/onboarding/debug/release.js +12 -0
- package/dist/commands/onboarding/debug/resume.d.ts +63 -0
- package/dist/commands/onboarding/debug/resume.js +12 -0
- package/dist/commands/onboarding/debug/status.d.ts +63 -0
- package/dist/commands/onboarding/debug/status.js +12 -0
- package/dist/commands/onboarding/debug/step.d.ts +67 -0
- package/dist/commands/onboarding/debug/step.js +15 -0
- package/dist/commands/onboarding/files/list.d.ts +58 -0
- package/dist/commands/onboarding/files/list.js +12 -0
- package/dist/commands/onboarding/files/read.d.ts +73 -0
- package/dist/commands/onboarding/files/read.js +16 -0
- package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
- package/dist/commands/onboarding/files/rebuild.js +18 -0
- package/dist/commands/onboarding/files/validate.d.ts +58 -0
- package/dist/commands/onboarding/files/validate.js +12 -0
- package/dist/commands/onboarding/fouc.d.ts +77 -0
- package/dist/commands/onboarding/fouc.js +16 -0
- package/dist/commands/onboarding/inject/add.d.ts +89 -0
- package/dist/commands/onboarding/inject/add.js +17 -0
- package/dist/commands/onboarding/inject/clear.d.ts +63 -0
- package/dist/commands/onboarding/inject/clear.js +12 -0
- package/dist/commands/onboarding/inject/list.d.ts +63 -0
- package/dist/commands/onboarding/inject/list.js +12 -0
- package/dist/commands/onboarding/inject/read.d.ts +75 -0
- package/dist/commands/onboarding/inject/read.js +18 -0
- package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
- package/dist/commands/onboarding/inject/recipes.js +12 -0
- package/dist/commands/onboarding/inject/remove.d.ts +67 -0
- package/dist/commands/onboarding/inject/remove.js +15 -0
- package/dist/commands/onboarding/list.d.ts +13 -0
- package/dist/commands/onboarding/list.js +12 -0
- package/dist/commands/onboarding/logs.d.ts +41 -0
- package/dist/commands/onboarding/logs.js +256 -0
- package/dist/commands/onboarding/navwalk.d.ts +95 -0
- package/dist/commands/onboarding/navwalk.js +19 -0
- package/dist/commands/onboarding/response.d.ts +67 -0
- package/dist/commands/onboarding/response.js +18 -0
- package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
- package/dist/commands/onboarding/rum/beacons.js +16 -0
- package/dist/commands/onboarding/rum/get.d.ts +77 -0
- package/dist/commands/onboarding/rum/get.js +18 -0
- package/dist/commands/onboarding/rum/key.d.ts +67 -0
- package/dist/commands/onboarding/rum/key.js +13 -0
- package/dist/commands/onboarding/rum/previous.d.ts +63 -0
- package/dist/commands/onboarding/rum/previous.js +12 -0
- package/dist/commands/onboarding/status.d.ts +13 -0
- package/dist/commands/onboarding/status.js +17 -0
- package/dist/commands/onboarding/todo.d.ts +58 -0
- package/dist/commands/onboarding/todo.js +12 -0
- package/dist/commands/onboarding/viewport.d.ts +101 -0
- package/dist/commands/onboarding/viewport.js +18 -0
- package/dist/commands/onboarding/watch.d.ts +93 -0
- package/dist/commands/onboarding/watch.js +16 -0
- package/dist/commands/onboarding.d.ts +26 -0
- package/dist/commands/onboarding.js +220 -3
- package/dist/commands/origin-request.d.ts +4 -0
- package/dist/commands/origin-request.js +4 -0
- package/dist/commands/spec/onboarding.spec.d.ts +1 -0
- package/dist/commands/spec/onboarding.spec.js +127 -0
- package/dist/services/cli/build-info.d.ts +33 -0
- package/dist/services/cli/build-info.js +63 -0
- package/dist/services/cli/cli-environment-factory.d.ts +3 -0
- package/dist/services/cli/cli-environment-factory.js +1 -0
- package/dist/services/cli/cli-service-build-context.d.ts +3 -0
- package/dist/services/cli/cli-service-factory.js +1 -1
- package/dist/services/cli/cli-service-model.d.ts +29 -10
- package/dist/services/cli/cli-service.d.ts +60 -11
- package/dist/services/cli/cli-service.js +196 -32
- package/dist/services/cli/index.d.ts +2 -0
- package/dist/services/cli/index.js +2 -0
- package/dist/services/cli/sink.d.ts +47 -0
- package/dist/services/cli/sink.js +31 -0
- package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
- package/dist/services/cli/spec/build-identity.spec.js +85 -0
- package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
- package/dist/services/cli/spec/build-info.spec.js +10 -0
- package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
- package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
- package/dist/services/cli/spec/cli-service.spec.js +113 -50
- package/dist/services/cli/spec/memory-cli.d.ts +9 -0
- package/dist/services/cli/spec/memory-cli.js +9 -0
- package/dist/services/diff/config-at-ref.d.ts +20 -0
- package/dist/services/diff/config-at-ref.js +33 -0
- package/dist/services/diff/diff-service-build-context.d.ts +8 -0
- package/dist/services/diff/diff-service-build-context.js +40 -1
- package/dist/services/diff/diff-service-factory.d.ts +2 -0
- package/dist/services/diff/diff-service-factory.js +48 -20
- package/dist/services/diff/diff-service.d.ts +11 -0
- package/dist/services/diff/diff-service.js +37 -11
- package/dist/services/diff/page-source.d.ts +12 -0
- package/dist/services/diff/page-source.js +16 -11
- package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
- package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
- package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
- package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
- package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
- package/dist/services/diff/spec/diff-service.spec.js +95 -0
- package/dist/services/git/git-repository.d.ts +2 -0
- package/dist/services/git/git-repository.js +6 -0
- package/dist/services/integration-api/customer-config-flags.js +1 -0
- package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
- package/dist/services/onboarding/browser/baqend-response.js +23 -0
- package/dist/services/onboarding/browser/console-log.d.ts +9 -0
- package/dist/services/onboarding/browser/console-log.js +27 -0
- package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
- package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
- package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
- package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
- package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
- package/dist/services/onboarding/control/body-inspect.js +106 -0
- package/dist/services/onboarding/control/browser-session.d.ts +521 -0
- package/dist/services/onboarding/control/browser-session.js +1273 -0
- package/dist/services/onboarding/control/config-validation.d.ts +17 -0
- package/dist/services/onboarding/control/config-validation.js +46 -0
- package/dist/services/onboarding/control/control-protocol.d.ts +1390 -0
- package/dist/services/onboarding/control/control-protocol.js +69 -0
- package/dist/services/onboarding/control/control-server.d.ts +284 -0
- package/dist/services/onboarding/control/control-server.js +1609 -0
- package/dist/services/onboarding/control/debug-session.d.ts +190 -0
- package/dist/services/onboarding/control/debug-session.js +801 -0
- package/dist/services/onboarding/control/fouc.d.ts +23 -0
- package/dist/services/onboarding/control/fouc.js +151 -0
- package/dist/services/onboarding/control/index.d.ts +4 -0
- package/dist/services/onboarding/control/index.js +4 -0
- package/dist/services/onboarding/control/navwalk.d.ts +65 -0
- package/dist/services/onboarding/control/navwalk.js +248 -0
- package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
- package/dist/services/onboarding/control/preload-registry.js +829 -0
- package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
- package/dist/services/onboarding/control/response-explainer.js +257 -0
- package/dist/services/onboarding/control/rum.d.ts +8 -0
- package/dist/services/onboarding/control/rum.js +220 -0
- package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
- package/dist/services/onboarding/control/service-worker-tracker.js +119 -0
- package/dist/services/onboarding/control/viewport.d.ts +45 -0
- package/dist/services/onboarding/control/viewport.js +344 -0
- package/dist/services/onboarding/control/watch.d.ts +26 -0
- package/dist/services/onboarding/control/watch.js +149 -0
- package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
- package/dist/services/onboarding/dashboard/index.js +7 -2
- package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
- package/dist/services/onboarding/fetch-event-handler.js +94 -32
- package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
- package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
- package/dist/services/onboarding/file-events/file-watcher.js +117 -12
- package/dist/services/onboarding/onboarding-model.d.ts +30 -0
- package/dist/services/onboarding/onboarding-model.js +10 -0
- package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
- package/dist/services/onboarding/onboarding-service-build-context.js +6 -0
- package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
- package/dist/services/onboarding/onboarding-service-factory.js +131 -17
- package/dist/services/onboarding/onboarding-service.d.ts +40 -1
- package/dist/services/onboarding/onboarding-service.js +135 -22
- package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
- package/dist/services/onboarding/request-cache/asset-key.js +115 -0
- package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
- package/dist/services/onboarding/request-cache/cache.js +128 -17
- package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
- package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/browser-session.spec.js +526 -0
- package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/control-server.spec.js +338 -0
- package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/debug-session.spec.js +693 -0
- package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
- package/dist/services/onboarding/spec/control/fakes.js +66 -0
- package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
- package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
- package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
- package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
- package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
- package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
- package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
- package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/watch.spec.js +172 -0
- package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/fetch-event-handler.spec.js +202 -0
- package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
- package/dist/services/onboarding/spec/onboarding-model.spec.js +37 -0
- package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +1 -0
- package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
- package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
- package/dist/services/onboarding/todo-collector.d.ts +7 -2
- package/dist/services/onboarding/todo-collector.js +49 -12
- package/dist/services/onboarding/virtual-orestes-app/index.d.ts +34 -0
- package/dist/services/onboarding/virtual-orestes-app/index.js +82 -27
- package/dist/services/origin-request/asset-variations.d.ts +14 -0
- package/dist/services/origin-request/asset-variations.js +11 -4
- package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
- package/dist/services/origin-request/origin-fetcher.js +43 -5
- package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
- package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
- package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
- package/dist/services/origin-request/origin-request-service-factory.js +2 -30
- package/dist/services/origin-request/origin-request-service.d.ts +121 -6
- package/dist/services/origin-request/origin-request-service.js +273 -49
- package/dist/services/origin-request/runtime-config-source.js +9 -4
- package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
- package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
- package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
- package/dist/services/query-builder/rules/rule-match.js +70 -0
- package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
- package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
- package/dist/services/run-control/browser/run-browser-contexts.d.ts +541 -0
- package/dist/services/run-control/browser/run-browser-contexts.js +78 -0
- package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
- package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
- package/dist/services/run-control/browser/run-browser-service.d.ts +64 -0
- package/dist/services/run-control/browser/run-browser-service.js +199 -0
- package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
- package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
- package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
- package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
- package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
- package/dist/services/run-control/cache/run-cache-service.js +151 -0
- package/dist/services/run-control/control-client.d.ts +36 -0
- package/dist/services/run-control/control-client.js +147 -0
- package/dist/services/run-control/debug/run-debug-contexts.d.ts +411 -0
- package/dist/services/run-control/debug/run-debug-contexts.js +44 -0
- package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
- package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
- package/dist/services/run-control/debug/run-debug-service.d.ts +38 -0
- package/dist/services/run-control/debug/run-debug-service.js +161 -0
- package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
- package/dist/services/run-control/files/run-files-contexts.js +26 -0
- package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
- package/dist/services/run-control/files/run-files-service-factory.js +7 -0
- package/dist/services/run-control/files/run-files-service.d.ts +29 -0
- package/dist/services/run-control/files/run-files-service.js +120 -0
- package/dist/services/run-control/index.d.ts +32 -0
- package/dist/services/run-control/index.js +31 -0
- package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
- package/dist/services/run-control/inject/run-inject-contexts.js +32 -0
- package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
- package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
- package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
- package/dist/services/run-control/inject/run-inject-service.js +203 -0
- package/dist/services/run-control/live-run.d.ts +37 -0
- package/dist/services/run-control/live-run.js +56 -0
- package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
- package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
- package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
- package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
- package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
- package/dist/services/run-control/probe/run-probe-service.js +193 -0
- package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
- package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
- package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
- package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
- package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
- package/dist/services/run-control/rum/run-rum-service.js +122 -0
- package/dist/services/run-control/run-answer.d.ts +28 -0
- package/dist/services/run-control/run-answer.js +58 -0
- package/dist/services/run-control/run-control-context.d.ts +102 -0
- package/dist/services/run-control/run-control-context.js +36 -0
- package/dist/services/run-control/run-control-flags.d.ts +12 -0
- package/dist/services/run-control/run-control-flags.js +22 -0
- package/dist/services/run-control/run-control-model.d.ts +9 -0
- package/dist/services/run-control/run-control-model.js +1 -0
- package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
- package/dist/services/run-control/run-control-service-factory.js +26 -0
- package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
- package/dist/services/run-control/session/run-session-contexts.js +20 -0
- package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
- package/dist/services/run-control/session/run-session-service-factory.js +18 -0
- package/dist/services/run-control/session/run-session-service.d.ts +25 -0
- package/dist/services/run-control/session/run-session-service.js +95 -0
- package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/browser/run-browser-service.spec.js +327 -0
- package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
- package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
- package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
- package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/inject/run-inject-service.spec.js +224 -0
- package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
- package/dist/services/run-control/spec/live-run-fixture.js +109 -0
- package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
- package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
- package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
- package/dist/services/run-control/spec/run-answer.spec.js +57 -0
- package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/session/run-session-service.spec.js +101 -0
- package/dist/services/run-log/crash-mirror.d.ts +31 -0
- package/dist/services/run-log/crash-mirror.js +69 -0
- package/dist/services/run-log/index.d.ts +11 -0
- package/dist/services/run-log/index.js +11 -0
- package/dist/services/run-log/jsonl-appender.d.ts +46 -0
- package/dist/services/run-log/jsonl-appender.js +91 -0
- package/dist/services/run-log/log-event-model.d.ts +104 -0
- package/dist/services/run-log/log-event-model.js +56 -0
- package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
- package/dist/services/run-log/log-query-service-factory.js +14 -0
- package/dist/services/run-log/log-query-service.d.ts +59 -0
- package/dist/services/run-log/log-query-service.js +111 -0
- package/dist/services/run-log/log-reader.d.ts +84 -0
- package/dist/services/run-log/log-reader.js +180 -0
- package/dist/services/run-log/log-summary.d.ts +72 -0
- package/dist/services/run-log/log-summary.js +208 -0
- package/dist/services/run-log/redaction.d.ts +34 -0
- package/dist/services/run-log/redaction.js +124 -0
- package/dist/services/run-log/request-log.d.ts +80 -0
- package/dist/services/run-log/request-log.js +69 -0
- package/dist/services/run-log/request-summary.d.ts +76 -0
- package/dist/services/run-log/request-summary.js +0 -0
- package/dist/services/run-log/run-log.d.ts +61 -0
- package/dist/services/run-log/run-log.js +102 -0
- package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
- package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
- package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
- package/dist/services/run-log/spec/log-reader.spec.js +109 -0
- package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
- package/dist/services/run-log/spec/log-summary.spec.js +153 -0
- package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
- package/dist/services/run-log/spec/redaction.spec.js +61 -0
- package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
- package/dist/services/run-log/spec/request-log.spec.js +101 -0
- package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
- package/dist/services/run-log/spec/request-summary.spec.js +171 -0
- package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
- package/dist/services/run-log/spec/run-log.spec.js +122 -0
- package/dist/services/run-registry/exit-classification.d.ts +39 -0
- package/dist/services/run-registry/exit-classification.js +42 -0
- package/dist/services/run-registry/index.d.ts +3 -0
- package/dist/services/run-registry/index.js +3 -0
- package/dist/services/run-registry/process-identity.d.ts +28 -0
- package/dist/services/run-registry/process-identity.js +80 -0
- package/dist/services/run-registry/run-registry-model.d.ts +128 -0
- package/dist/services/run-registry/run-registry-model.js +16 -0
- package/dist/services/run-registry/run-registry.d.ts +150 -0
- package/dist/services/run-registry/run-registry.js +409 -0
- package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
- package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
- package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
- package/dist/services/run-registry/spec/run-registry.spec.js +509 -0
- package/dist/services/setup/os/tool-registry.js +2 -2
- package/oclif.manifest.json +3293 -272
- package/package.json +20 -2
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { beforeEach, describe, it } from "mocha";
|
|
3
|
+
import { EventEmitter } from "node:events";
|
|
4
|
+
import { MemoryRequestLog } from "../../run-log/index.js";
|
|
5
|
+
import { AbortResponse } from "../browser/abort-response.js";
|
|
6
|
+
import { FetchEventHandler } from "../fetch-event-handler.js";
|
|
7
|
+
import { BROWSER_EVENTS } from "../onboarding-model.js";
|
|
8
|
+
/** A CDP session that records what it was told to do and answers immediately. */
|
|
9
|
+
class StubSession extends EventEmitter {
|
|
10
|
+
sent = [];
|
|
11
|
+
async send(method, params) {
|
|
12
|
+
this.sent.push({ method, params });
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** A handler that claims one url pattern and answers it however the spec says. */
|
|
17
|
+
class TestHandler {
|
|
18
|
+
answer;
|
|
19
|
+
patterns = [{ urlPattern: ".*", requestStage: "Request" }];
|
|
20
|
+
constructor(answer) {
|
|
21
|
+
this.answer = answer;
|
|
22
|
+
}
|
|
23
|
+
async handle() {
|
|
24
|
+
return this.answer;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Named so a record's `handler` field has something recognisable in it. */
|
|
28
|
+
class SlowHandler extends TestHandler {
|
|
29
|
+
}
|
|
30
|
+
const cli = {
|
|
31
|
+
writeError: () => undefined,
|
|
32
|
+
writeWarning: () => undefined,
|
|
33
|
+
writeSuccess: () => undefined,
|
|
34
|
+
startAction: () => undefined,
|
|
35
|
+
successAction: () => undefined,
|
|
36
|
+
failAction: () => undefined,
|
|
37
|
+
};
|
|
38
|
+
const customerConfig = {
|
|
39
|
+
origins: [],
|
|
40
|
+
app: "spec",
|
|
41
|
+
};
|
|
42
|
+
function pausedEvent(patch = {}) {
|
|
43
|
+
return {
|
|
44
|
+
requestId: "1",
|
|
45
|
+
request: { url: "https://x.test/page", method: "GET" },
|
|
46
|
+
resourceType: "Document",
|
|
47
|
+
...patch,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Drive one paused request through the handler and return what was recorded. */
|
|
51
|
+
async function intercept(handlers, event = pausedEvent()) {
|
|
52
|
+
const requestLog = new MemoryRequestLog();
|
|
53
|
+
const session = new StubSession();
|
|
54
|
+
const target = {
|
|
55
|
+
createCDPSession: async () => session,
|
|
56
|
+
url: () => "https://x.test/",
|
|
57
|
+
};
|
|
58
|
+
const fetchEventHandler = new FetchEventHandler({
|
|
59
|
+
browserFetchEvents: handlers,
|
|
60
|
+
customerConfig,
|
|
61
|
+
cli,
|
|
62
|
+
requestLog,
|
|
63
|
+
});
|
|
64
|
+
await fetchEventHandler.handleRequestFetchEvents(target);
|
|
65
|
+
session.emit(BROWSER_EVENTS.FETCH_REQUEST_PAUSED, event);
|
|
66
|
+
// The listener is async and the emit does not await it.
|
|
67
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
68
|
+
return { requestLog, session };
|
|
69
|
+
}
|
|
70
|
+
/** Drive one auth challenge through the handler and return what CDP was told. */
|
|
71
|
+
async function challenge(authentications) {
|
|
72
|
+
const session = new StubSession();
|
|
73
|
+
const target = {
|
|
74
|
+
createCDPSession: async () => session,
|
|
75
|
+
url: () => "https://x.test/",
|
|
76
|
+
};
|
|
77
|
+
const client = {
|
|
78
|
+
getServerConfig: async () => JSON.stringify({ speedKit: { authentications } }),
|
|
79
|
+
};
|
|
80
|
+
const fetchEventHandler = new FetchEventHandler({
|
|
81
|
+
browserFetchEvents: [],
|
|
82
|
+
customerConfig: {
|
|
83
|
+
origins: ["https://x.test"],
|
|
84
|
+
app: "spec",
|
|
85
|
+
},
|
|
86
|
+
cli,
|
|
87
|
+
client: client,
|
|
88
|
+
requestLog: new MemoryRequestLog(),
|
|
89
|
+
});
|
|
90
|
+
await fetchEventHandler.handleRequestFetchEvents(target);
|
|
91
|
+
session.emit(BROWSER_EVENTS.FETCH_AUTH_REQUIRED, {
|
|
92
|
+
requestId: "1",
|
|
93
|
+
request: { url: "https://x.test/page" },
|
|
94
|
+
authChallenge: { scheme: "basic", origin: "https://x.test" },
|
|
95
|
+
});
|
|
96
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
97
|
+
return session.sent.filter((call) => call.method === "Fetch.continueWithAuth");
|
|
98
|
+
}
|
|
99
|
+
describe("FetchEventHandler auth challenges", () => {
|
|
100
|
+
it("should answer a challenge exactly once when credentials are found", async () => {
|
|
101
|
+
// It used to send the credentials and then send `Default` for the same
|
|
102
|
+
// requestId. A challenge can only be answered once, so the second call
|
|
103
|
+
// always threw `Invalid state for continueInterceptedRequest` — logged at
|
|
104
|
+
// `error` level, one millisecond after the success line, and heading the
|
|
105
|
+
// run's problems list as though authentication had failed. It had not: the
|
|
106
|
+
// credentials went first.
|
|
107
|
+
const calls = await challenge([
|
|
108
|
+
{
|
|
109
|
+
uri: "https://x.test",
|
|
110
|
+
type: "basic",
|
|
111
|
+
user: "spec",
|
|
112
|
+
password: "spec-secret",
|
|
113
|
+
},
|
|
114
|
+
]);
|
|
115
|
+
expect(calls).to.have.lengthOf(1);
|
|
116
|
+
expect(calls[0].params.authChallengeResponse.response).to.equal("ProvideCredentials");
|
|
117
|
+
});
|
|
118
|
+
it("should fall back to the default behaviour when no credential matches", async () => {
|
|
119
|
+
// The other origin's credential must not be offered here, and the
|
|
120
|
+
// challenge still has to be answered, or the request hangs.
|
|
121
|
+
const calls = await challenge([
|
|
122
|
+
{ uri: "https://other.test", type: "basic", user: "u", password: "p" },
|
|
123
|
+
]);
|
|
124
|
+
expect(calls).to.have.lengthOf(1);
|
|
125
|
+
expect(calls[0].params.authChallengeResponse.response).to.equal("Default");
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
describe("FetchEventHandler request records", () => {
|
|
129
|
+
let handled;
|
|
130
|
+
describe("a request no handler claims", () => {
|
|
131
|
+
beforeEach(async () => {
|
|
132
|
+
handled = await intercept([]);
|
|
133
|
+
});
|
|
134
|
+
it("is recorded as continued", async () => {
|
|
135
|
+
// The one outcome with no other trace anywhere: "what did the CLI hand
|
|
136
|
+
// straight back to Chrome" is exactly what a disabledScopes or blacklist
|
|
137
|
+
// change moves, and nothing else in the run writes it down.
|
|
138
|
+
expect(handled.requestLog.records).to.have.length(1);
|
|
139
|
+
expect(handled.requestLog.records[0]).to.include({
|
|
140
|
+
outcome: "continued",
|
|
141
|
+
url: "https://x.test/page",
|
|
142
|
+
method: "GET",
|
|
143
|
+
resourceType: "Document",
|
|
144
|
+
stage: "Request",
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
it("still reaches Chrome untouched", async () => {
|
|
148
|
+
expect(handled.session.sent.map((call) => call.method)).to.contain("Fetch.continueRequest");
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
it("records the handler that answered, and the status", async () => {
|
|
152
|
+
const { requestLog } = await intercept([
|
|
153
|
+
new SlowHandler({ responseCode: 203, body: "" }),
|
|
154
|
+
]);
|
|
155
|
+
expect(requestLog.records[0]).to.include({
|
|
156
|
+
outcome: "fulfilled",
|
|
157
|
+
handler: "SlowHandler",
|
|
158
|
+
status: 203,
|
|
159
|
+
});
|
|
160
|
+
expect(requestLog.records[0].durationMs).to.be.a("number");
|
|
161
|
+
});
|
|
162
|
+
it("records a deliberate abort as failed, not as an error", async () => {
|
|
163
|
+
// An abort is a rule doing its job. Recording it as an error would put a
|
|
164
|
+
// working config at the top of the summary's problem list.
|
|
165
|
+
const { requestLog } = await intercept([
|
|
166
|
+
new TestHandler(new AbortResponse("Aborted")),
|
|
167
|
+
]);
|
|
168
|
+
expect(requestLog.records[0].outcome).to.equal("failed");
|
|
169
|
+
});
|
|
170
|
+
it("records a handler that threw, with the reason", async () => {
|
|
171
|
+
const thrower = {
|
|
172
|
+
patterns: [{ urlPattern: ".*", requestStage: "Request" }],
|
|
173
|
+
handle: async () => {
|
|
174
|
+
throw new Error("handler blew up");
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
const { requestLog } = await intercept([thrower]);
|
|
178
|
+
expect(requestLog.records[0]).to.include({ outcome: "error" });
|
|
179
|
+
expect(requestLog.records[0].error).to.contain("handler blew up");
|
|
180
|
+
});
|
|
181
|
+
it("distinguishes the response stage from the request stage", async () => {
|
|
182
|
+
const { requestLog } = await intercept([], pausedEvent({ responseHeaders: [{ name: "x", value: "y" }] }));
|
|
183
|
+
expect(requestLog.records[0].stage).to.equal("Response");
|
|
184
|
+
});
|
|
185
|
+
it("works without a request log at all", async () => {
|
|
186
|
+
// A run started with --no-log-file, and the test harness.
|
|
187
|
+
const session = new StubSession();
|
|
188
|
+
const target = {
|
|
189
|
+
createCDPSession: async () => session,
|
|
190
|
+
url: () => "https://x.test/",
|
|
191
|
+
};
|
|
192
|
+
const handler = new FetchEventHandler({
|
|
193
|
+
browserFetchEvents: [],
|
|
194
|
+
customerConfig,
|
|
195
|
+
cli,
|
|
196
|
+
});
|
|
197
|
+
await handler.handleRequestFetchEvents(target);
|
|
198
|
+
session.emit(BROWSER_EVENTS.FETCH_REQUEST_PAUSED, pausedEvent());
|
|
199
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
200
|
+
expect(session.sent.map((call) => call.method)).to.contain("Fetch.continueRequest");
|
|
201
|
+
});
|
|
202
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
|
+
import { createContext, runInContext } from "node:vm";
|
|
4
|
+
import { SpeedKitServiceWorkerJs, userAgentPrelude, } from "../../fetch-events/speed-kit-service-worker-js.js";
|
|
5
|
+
const MOBILE = "Mozilla/5.0 (Linux; Android 10; K) Mobile Safari/537.36";
|
|
6
|
+
/** A worker global whose navigator has the user agent on its prototype, as Chrome's does. */
|
|
7
|
+
function worker() {
|
|
8
|
+
const prototype = {};
|
|
9
|
+
Object.defineProperty(prototype, "userAgent", {
|
|
10
|
+
get: () => "Mozilla/5.0 (X11; Linux x86_64) Chrome/146",
|
|
11
|
+
configurable: true,
|
|
12
|
+
});
|
|
13
|
+
const navigator = Object.create(prototype);
|
|
14
|
+
const context = createContext({ self: { navigator }, navigator });
|
|
15
|
+
return { navigator, run: (source) => runInContext(source, context) };
|
|
16
|
+
}
|
|
17
|
+
describe("SpeedKitServiceWorkerJs under emulation", () => {
|
|
18
|
+
const handler = () => new SpeedKitServiceWorkerJs({ appDomain: "myapp.app.baqend.com" }, {
|
|
19
|
+
getContent: () => "/* speed kit */ self.ua = navigator.userAgent;",
|
|
20
|
+
});
|
|
21
|
+
const body = async (sw) => {
|
|
22
|
+
const response = await sw.handle();
|
|
23
|
+
return Buffer.from(String(response.body), "base64").toString("utf8");
|
|
24
|
+
};
|
|
25
|
+
it("should make the worker report the emulated user agent", () => {
|
|
26
|
+
// Speed Kit decides the device in its worker, from navigator.userAgent
|
|
27
|
+
// when no header says otherwise. A CDP override did not reach it.
|
|
28
|
+
const { navigator, run } = worker();
|
|
29
|
+
run(userAgentPrelude(MOBILE));
|
|
30
|
+
expect(navigator.userAgent).to.equal(MOBILE);
|
|
31
|
+
});
|
|
32
|
+
it("should prepend the override only while an emulation is active", async () => {
|
|
33
|
+
const sw = handler();
|
|
34
|
+
expect(await body(sw)).to.not.contain("sk onboarding browser emulate");
|
|
35
|
+
sw.userAgent = MOBILE;
|
|
36
|
+
const emulated = await body(sw);
|
|
37
|
+
// First, so it runs before any of Speed Kit's code reads the user agent.
|
|
38
|
+
expect(emulated.indexOf("sk onboarding browser emulate")).to.equal(3);
|
|
39
|
+
expect(emulated).to.contain("/* speed kit */");
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -294,4 +294,41 @@ describe("BrowserContext launch options", () => {
|
|
|
294
294
|
expect(options.enableExtensions).to.equal(undefined);
|
|
295
295
|
expect(options.pipe).to.equal(undefined);
|
|
296
296
|
});
|
|
297
|
+
it("should keep the signals for itself", () => {
|
|
298
|
+
const options = newContext(false).getPuppeteerLaunchOptions();
|
|
299
|
+
// Puppeteer's own SIGINT handler is `kill(); process.exit(130)`, which
|
|
300
|
+
// would skip the run's status stamp, the control-socket unlink and the
|
|
301
|
+
// cache teardown — everything in the command's `finally`. The command
|
|
302
|
+
// registers its handlers before the browser launches and owns shutdown.
|
|
303
|
+
expect(options.handleSIGINT).to.equal(false);
|
|
304
|
+
expect(options.handleSIGTERM).to.equal(false);
|
|
305
|
+
expect(options.handleSIGHUP).to.equal(false);
|
|
306
|
+
});
|
|
307
|
+
it("installs extensions over the pipe on every Chromium build", () => {
|
|
308
|
+
const withExtensions = {
|
|
309
|
+
settings: {
|
|
310
|
+
...environment.settings,
|
|
311
|
+
chromeExtensionPaths: "/ext/devtools,/ext/other",
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
for (const browserVersionString of [
|
|
315
|
+
"Google Chrome for Testing 154.0.8037.57",
|
|
316
|
+
"Chromium 153.0.8010.52 Arch Linux",
|
|
317
|
+
]) {
|
|
318
|
+
const options = new BrowserContext("example.com", browserVersionString, [], withExtensions, undefined, false, false, undefined).getPuppeteerLaunchOptions();
|
|
319
|
+
// The pipe and Puppeteer's --enable-unsafe-extension-debugging are what
|
|
320
|
+
// the `Extensions` domain requires, and ExtensionBridge writes through it.
|
|
321
|
+
expect(options.pipe).to.equal(true);
|
|
322
|
+
expect(options.enableExtensions).to.deep.equal([
|
|
323
|
+
"/ext/devtools",
|
|
324
|
+
"/ext/other",
|
|
325
|
+
]);
|
|
326
|
+
expect(options.args.filter((arg) => /extension/.test(arg))).to.deep.equal([]);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
it("launches without extensions when none are configured", () => {
|
|
330
|
+
const options = newContext(false).getPuppeteerLaunchOptions();
|
|
331
|
+
expect(options.enableExtensions).to.equal(undefined);
|
|
332
|
+
expect(options.pipe).to.equal(undefined);
|
|
333
|
+
});
|
|
297
334
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { afterEach, beforeEach, describe, it } from "mocha";
|
|
3
|
+
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { BaqendResponse } from "../../browser/baqend-response.js";
|
|
7
|
+
import { Cache } from "../../request-cache/cache.js";
|
|
8
|
+
import { memoryCli } from "../../../cli/spec/memory-cli.js";
|
|
9
|
+
const KEY = "https://myapp.app.baqend.com/v1/asset/https://shop.example.com/p?bqvariation=mobile";
|
|
10
|
+
const PAGE = "<html><body>hello</body></html>";
|
|
11
|
+
describe("Cache", () => {
|
|
12
|
+
let directory;
|
|
13
|
+
let cache;
|
|
14
|
+
const add = (key, body, status) => cache.addEntry(key, new BaqendResponse(body, "text/html; charset=utf-8", [], status), body);
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
directory = mkdtempSync(join(tmpdir(), "sk-cache-"));
|
|
17
|
+
cache = new Cache(memoryCli(), directory);
|
|
18
|
+
});
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
rmSync(directory, { recursive: true, force: true });
|
|
21
|
+
});
|
|
22
|
+
it("should store the body decoded, so the file is simply readable", () => {
|
|
23
|
+
add(KEY, PAGE);
|
|
24
|
+
const [[, entry]] = [...cache.getAll()];
|
|
25
|
+
// Only Chrome's fulfillRequest needs base64; nothing else should pay for it.
|
|
26
|
+
expect(readFileSync(entry.path, "utf8")).to.equal(PAGE);
|
|
27
|
+
expect(entry.bytes).to.equal(PAGE.length);
|
|
28
|
+
});
|
|
29
|
+
it("should hand back a response Chrome can fulfil", () => {
|
|
30
|
+
add(KEY, PAGE);
|
|
31
|
+
const response = cache.getEntry(KEY);
|
|
32
|
+
expect(Buffer.from(response.body, "base64").toString("utf8")).to.equal(PAGE);
|
|
33
|
+
expect(response.responseCode).to.equal(200);
|
|
34
|
+
expect(response.contentLength).to.equal(PAGE.length);
|
|
35
|
+
});
|
|
36
|
+
it("should not accumulate headers, nor let a hit write back to the store", () => {
|
|
37
|
+
add(KEY, PAGE);
|
|
38
|
+
const first = cache.getEntry(KEY);
|
|
39
|
+
first.setHeader("x-cache", "POP, HIT");
|
|
40
|
+
const second = cache.getEntry(KEY);
|
|
41
|
+
// Rebuilding through the constructor would re-append `via` and friends on
|
|
42
|
+
// every hit, compounding for the life of the run.
|
|
43
|
+
expect(second.responseHeaders.filter((header) => header.name === "via")).to.have.lengthOf(1);
|
|
44
|
+
// And what one hit set must not leak into the next: the stored headers are
|
|
45
|
+
// copied out, not handed out.
|
|
46
|
+
expect(second.responseHeaders.find((header) => header.name === "x-cache")).to.equal(undefined);
|
|
47
|
+
});
|
|
48
|
+
it("should key a page apart from Speed Kit's bookkeeping on the request", () => {
|
|
49
|
+
// The page asks with its config and Speed Kit versions and a
|
|
50
|
+
// page-impression counter; `cache prewarm` builds the bare url. Keyed raw,
|
|
51
|
+
// the prewarmed entry was never the one the page read, and the page's own
|
|
52
|
+
// second request missed its first because the counter moved.
|
|
53
|
+
add(KEY, PAGE);
|
|
54
|
+
const fromPage = `${KEY}&bqcv=7f2b0065&bqsk=2.22.5&bqpi=1;sp=1&bqcache=if-cached`;
|
|
55
|
+
expect(cache.has(fromPage)).to.equal(true);
|
|
56
|
+
expect(cache.getEntry(fromPage)?.responseCode).to.equal(200);
|
|
57
|
+
expect([...cache.getAll()].map(([key]) => key)).to.deep.equal([KEY]);
|
|
58
|
+
});
|
|
59
|
+
it("should keep the variation and the page's own parameters in the key", () => {
|
|
60
|
+
add(KEY, PAGE);
|
|
61
|
+
expect(cache.has(KEY.replace("mobile", "tablet"))).to.equal(false);
|
|
62
|
+
expect(cache.has(`${KEY}&colour=red`)).to.equal(false);
|
|
63
|
+
});
|
|
64
|
+
it("should keep no body in memory", () => {
|
|
65
|
+
add(KEY, PAGE);
|
|
66
|
+
const [[, entry]] = [...cache.getAll()];
|
|
67
|
+
// The metadata is the whole in-memory footprint: the point of the change.
|
|
68
|
+
expect(Object.values(entry).join("")).to.not.contain("hello");
|
|
69
|
+
});
|
|
70
|
+
it("should treat a body that vanished as a miss, not a crash", () => {
|
|
71
|
+
add(KEY, PAGE);
|
|
72
|
+
const [[, entry]] = [...cache.getAll()];
|
|
73
|
+
rmSync(entry.path);
|
|
74
|
+
expect(cache.getEntry(KEY)).to.equal(null);
|
|
75
|
+
expect([...cache.getAll()]).to.have.lengthOf(0);
|
|
76
|
+
});
|
|
77
|
+
it("should give each key its own file, so evicting one keeps the other", () => {
|
|
78
|
+
// Content-addressing would share a file between these two and pull the body
|
|
79
|
+
// out from under the survivor.
|
|
80
|
+
add(`${KEY}&a=1`, PAGE);
|
|
81
|
+
add(`${KEY}&a=2`, PAGE);
|
|
82
|
+
cache.removeEntry("a=1");
|
|
83
|
+
expect([...cache.getAll()]).to.have.lengthOf(1);
|
|
84
|
+
expect(cache.getEntry(`${KEY}&a=2`)).to.not.equal(null);
|
|
85
|
+
});
|
|
86
|
+
it("should remove the files it wrote when cleared", () => {
|
|
87
|
+
add(`${KEY}&a=1`, PAGE);
|
|
88
|
+
add(`${KEY}&a=2`, PAGE);
|
|
89
|
+
cache.clear();
|
|
90
|
+
expect([...cache.getAll()]).to.have.lengthOf(0);
|
|
91
|
+
expect(readdirSync(directory)).to.deep.equal([]);
|
|
92
|
+
});
|
|
93
|
+
it("should overwrite an entry in place when it is cached again", () => {
|
|
94
|
+
add(KEY, PAGE);
|
|
95
|
+
const [[, first]] = [...cache.getAll()];
|
|
96
|
+
add(KEY, "<html>fresher</html>");
|
|
97
|
+
const [[, second]] = [...cache.getAll()];
|
|
98
|
+
expect(second.path).to.equal(first.path);
|
|
99
|
+
expect(second.sha).to.not.equal(first.sha);
|
|
100
|
+
expect(readdirSync(directory)).to.have.lengthOf(1);
|
|
101
|
+
});
|
|
102
|
+
it("should take the whole directory with it on destroy", () => {
|
|
103
|
+
add(KEY, PAGE);
|
|
104
|
+
cache.destroy();
|
|
105
|
+
expect(existsSync(directory)).to.equal(false);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
|
+
import { TodoCollector } from "../todo-collector.js";
|
|
4
|
+
import { FILE_TYPE } from "../../integration-api/index.js";
|
|
5
|
+
function resource(path, content, type = FILE_TYPE.CONFIG_FILE) {
|
|
6
|
+
return {
|
|
7
|
+
path,
|
|
8
|
+
type,
|
|
9
|
+
getContent: () => content,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
describe("TodoCollector", () => {
|
|
13
|
+
it("should find every task in a file, not only the first", () => {
|
|
14
|
+
// The original matched with a non-global regex through `String.replace`,
|
|
15
|
+
// which calls its replacer once. A file with four open tasks reported one
|
|
16
|
+
// and the rest were invisible — to the devtools panel and to anything else.
|
|
17
|
+
const collector = new TodoCollector([
|
|
18
|
+
resource("/customers/x/production/config_SpeedKit.js", [
|
|
19
|
+
"const a = 1;",
|
|
20
|
+
"// TODO ask about the split test",
|
|
21
|
+
"one",
|
|
22
|
+
"two",
|
|
23
|
+
"three",
|
|
24
|
+
"const b = 2;",
|
|
25
|
+
"// TODO confirm the asset list",
|
|
26
|
+
"four",
|
|
27
|
+
"five",
|
|
28
|
+
"six",
|
|
29
|
+
].join("\n")),
|
|
30
|
+
]);
|
|
31
|
+
const tasks = collector.getOpenTasks();
|
|
32
|
+
expect(tasks.map((task) => task.todo.trim())).to.deep.equal([
|
|
33
|
+
"TODO ask about the split test",
|
|
34
|
+
"TODO confirm the asset list",
|
|
35
|
+
]);
|
|
36
|
+
});
|
|
37
|
+
it("should give each task its own line, even when two read the same", () => {
|
|
38
|
+
// The line came from `indexOf(todoText)`, so a repeated task all pointed at
|
|
39
|
+
// the first occurrence — and the point of the line is to open the file at it.
|
|
40
|
+
const collector = new TodoCollector([
|
|
41
|
+
resource("/customers/x/production/config_documentHandler.js", [
|
|
42
|
+
"// TODO check this",
|
|
43
|
+
"a",
|
|
44
|
+
"b",
|
|
45
|
+
"c",
|
|
46
|
+
"// TODO check this",
|
|
47
|
+
"d",
|
|
48
|
+
"e",
|
|
49
|
+
"f",
|
|
50
|
+
].join("\n")),
|
|
51
|
+
]);
|
|
52
|
+
const [first, second] = collector.getOpenTasks();
|
|
53
|
+
expect(first.line).to.not.equal(second.line);
|
|
54
|
+
expect(second.line).to.be.greaterThan(first.line);
|
|
55
|
+
});
|
|
56
|
+
it("should not start one file where the last one stopped", () => {
|
|
57
|
+
// A shared global regex carries `lastIndex` between calls, so the second
|
|
58
|
+
// file would begin matching from an offset that means nothing in it.
|
|
59
|
+
const body = ["// TODO one", "a", "b", "c"].join("\n");
|
|
60
|
+
const collector = new TodoCollector([
|
|
61
|
+
resource("/customers/x/production/first.js", `${body}\n${body}`),
|
|
62
|
+
resource("/customers/x/production/second.js", body),
|
|
63
|
+
]);
|
|
64
|
+
const files = collector.getOpenTasks().map((task) => task.file);
|
|
65
|
+
expect(files.filter((file) => file.endsWith("second.js"))).to.have.lengthOf(1);
|
|
66
|
+
});
|
|
67
|
+
it("should carry the file and the three lines under the task", () => {
|
|
68
|
+
const collector = new TodoCollector([
|
|
69
|
+
resource("/customers/x/production/config_SpeedKit.js", ["// TODO ask", "context one", "context two", "context three"].join("\n")),
|
|
70
|
+
]);
|
|
71
|
+
const [task] = collector.getOpenTasks();
|
|
72
|
+
expect(task.file).to.equal("/customers/x/production/config_SpeedKit.js");
|
|
73
|
+
expect(decodeURI(task.context)).to.contain("context one");
|
|
74
|
+
expect(decodeURI(task.context)).to.contain("context three");
|
|
75
|
+
});
|
|
76
|
+
it("should skip virtual files, which nobody can open in an editor", () => {
|
|
77
|
+
const collector = new TodoCollector([
|
|
78
|
+
resource("bundle_install", ["// TODO generated", "a", "b", "c"].join("\n"), FILE_TYPE.VIRTUAL_FILE),
|
|
79
|
+
]);
|
|
80
|
+
expect(collector.getOpenTasks()).to.deep.equal([]);
|
|
81
|
+
});
|
|
82
|
+
it("should find a task written inside the previous one's context", () => {
|
|
83
|
+
// The context used to be consumed, not looked ahead at, so `lastIndex`
|
|
84
|
+
// moved past the three lines under a TODO and a second one written inside
|
|
85
|
+
// that window was swallowed into the first one's `context` string. Two
|
|
86
|
+
// notes in a row is the ordinary way people write them.
|
|
87
|
+
const collector = new TodoCollector([
|
|
88
|
+
resource("/customers/x/production/config_SpeedKit.js", [
|
|
89
|
+
"// TODO confirm this scope with the customer",
|
|
90
|
+
"// TODO check the split test id",
|
|
91
|
+
"const a = 1;",
|
|
92
|
+
].join("\n")),
|
|
93
|
+
]);
|
|
94
|
+
expect(collector.getOpenTasks().map((task) => task.todo.trim())).to.deep.equal([
|
|
95
|
+
"TODO confirm this scope with the customer",
|
|
96
|
+
"TODO check the split test id",
|
|
97
|
+
]);
|
|
98
|
+
});
|
|
99
|
+
it("should not lose a task because it or the lines under it contain parentheses", () => {
|
|
100
|
+
// The text and all three context lines were `[^\n\r()|]*`, so a `(`, `)`
|
|
101
|
+
// or `|` anywhere in them failed the whole match and the task vanished —
|
|
102
|
+
// and a JS config is full of them. Both of these were invisible.
|
|
103
|
+
const collector = new TodoCollector([
|
|
104
|
+
resource("/customers/x/production/config_SpeedKit.js", [
|
|
105
|
+
"// TODO check the split test id (ask the customer) first",
|
|
106
|
+
"a",
|
|
107
|
+
"b",
|
|
108
|
+
"c",
|
|
109
|
+
"// TODO confirm the wishlist pattern",
|
|
110
|
+
"/wish(-)?list/i,",
|
|
111
|
+
"d",
|
|
112
|
+
"e",
|
|
113
|
+
].join("\n")),
|
|
114
|
+
]);
|
|
115
|
+
expect(collector.getOpenTasks().map((task) => task.todo.trim())).to.deep.equal([
|
|
116
|
+
"TODO check the split test id (ask the customer) first",
|
|
117
|
+
"TODO confirm the wishlist pattern",
|
|
118
|
+
]);
|
|
119
|
+
});
|
|
120
|
+
it("should report a task in the last lines of a file", () => {
|
|
121
|
+
// `{3}` required three lines beneath the TODO, so one written at the end
|
|
122
|
+
// of a file matched nothing at all.
|
|
123
|
+
const collector = new TodoCollector([
|
|
124
|
+
resource("/customers/x/production/config_SpeedKit.js", ["const a = 1;", "// TODO the last word"].join("\n")),
|
|
125
|
+
]);
|
|
126
|
+
const [task] = collector.getOpenTasks();
|
|
127
|
+
expect(task.todo.trim()).to.equal("TODO the last word");
|
|
128
|
+
expect(task.line).to.equal(2);
|
|
129
|
+
});
|
|
130
|
+
it("should answer an empty list when nothing is open", () => {
|
|
131
|
+
const collector = new TodoCollector([
|
|
132
|
+
resource("/customers/x/production/clean.js", "const a = 1;\n"),
|
|
133
|
+
]);
|
|
134
|
+
expect(collector.getOpenTasks()).to.deep.equal([]);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { InstallResourceInterface } from "../integration-api/integration-api-model.js";
|
|
2
2
|
export interface task {
|
|
3
3
|
todo: string;
|
|
4
|
+
/** The three lines beneath it, URI-encoded — see {@link TodoCollector}. */
|
|
4
5
|
context: string;
|
|
5
6
|
file: string;
|
|
6
7
|
line: number;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
10
|
+
* Collects the open tasks written into a customer's config files.
|
|
11
|
+
*
|
|
12
|
+
* Read by two consumers with different needs: the devtools panel, which the
|
|
13
|
+
* messages are shaped for, and `sk onboarding todo` over the control socket. `context` is
|
|
14
|
+
* URI-encoded because the panel's transport expects it that way; the control
|
|
15
|
+
* handler decodes it again rather than handing an agent percent-escapes.
|
|
11
16
|
*/
|
|
12
17
|
export declare class TodoCollector {
|
|
13
18
|
private files;
|
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
import { FILE_TYPE } from "../integration-api/index.js";
|
|
2
|
-
const TODO_MATCH = /(todo[^\n\r()|]*)((?:(?:\r\n|\r|\n)[^\n\r()|]*){3})/i;
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* A `TODO` and the three lines under it.
|
|
4
|
+
*
|
|
5
|
+
* Global on purpose. It used to be matched with a non-global regex through
|
|
6
|
+
* `String.replace`, which calls its replacer once — so a file with four open
|
|
7
|
+
* tasks reported one, and the other three were invisible to both the devtools
|
|
8
|
+
* panel and anything else that asked.
|
|
9
|
+
*
|
|
10
|
+
* Three further things that each silently dropped a task, all of them found
|
|
11
|
+
* against a real config:
|
|
12
|
+
*
|
|
13
|
+
* - **The context is a lookahead.** Consuming the three lines moved
|
|
14
|
+
* `lastIndex` past them, so a second `TODO` written inside that window was
|
|
15
|
+
* swallowed into the first one's context and never reported. Two notes in a
|
|
16
|
+
* row is the ordinary way people write them.
|
|
17
|
+
* - **Parentheses are allowed.** The text and the context lines used to be
|
|
18
|
+
* `[^\n\r()|]*`, so a `(`, `)` or `|` anywhere in the task or in the three
|
|
19
|
+
* lines beneath it failed the whole match and the task vanished — and a JS
|
|
20
|
+
* config is full of them. `// TODO confirm the wishlist pattern` sitting one
|
|
21
|
+
* line above `/wish(-)?list/i` was invisible.
|
|
22
|
+
* - **Fewer than three lines is enough.** `{3}` required them, so a `TODO` in
|
|
23
|
+
* the last lines of a file matched nothing.
|
|
24
|
+
*/
|
|
25
|
+
const TODO_MATCH = /(todo[^\n\r]*)(?=((?:(?:\r\n|\r|\n)[^\n\r]*){0,3}))/gi;
|
|
26
|
+
/**
|
|
27
|
+
* Collects the open tasks written into a customer's config files.
|
|
28
|
+
*
|
|
29
|
+
* Read by two consumers with different needs: the devtools panel, which the
|
|
30
|
+
* messages are shaped for, and `sk onboarding todo` over the control socket. `context` is
|
|
31
|
+
* URI-encoded because the panel's transport expects it that way; the control
|
|
32
|
+
* handler decodes it again rather than handing an agent percent-escapes.
|
|
6
33
|
*/
|
|
7
34
|
export class TodoCollector {
|
|
8
35
|
files;
|
|
@@ -10,21 +37,31 @@ export class TodoCollector {
|
|
|
10
37
|
this.files = files;
|
|
11
38
|
}
|
|
12
39
|
getOpenTasks() {
|
|
13
|
-
const configFiles = this.files.filter((file) =>
|
|
14
|
-
return !(file.type === FILE_TYPE.VIRTUAL_FILE);
|
|
15
|
-
});
|
|
40
|
+
const configFiles = this.files.filter((file) => file.type !== FILE_TYPE.VIRTUAL_FILE);
|
|
16
41
|
const tasks = [];
|
|
17
42
|
for (const configFile of configFiles) {
|
|
18
43
|
const content = configFile.getContent();
|
|
19
|
-
|
|
44
|
+
// A fresh regex per file: a global one carries `lastIndex` between
|
|
45
|
+
// calls, so sharing the constant would make every second file start
|
|
46
|
+
// matching from wherever the previous one stopped.
|
|
47
|
+
const pattern = new RegExp(TODO_MATCH.source, TODO_MATCH.flags);
|
|
48
|
+
let match;
|
|
49
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
20
50
|
tasks.push({
|
|
21
|
-
todo:
|
|
22
|
-
context: encodeURI(
|
|
51
|
+
todo: match[1],
|
|
52
|
+
context: encodeURI(match[2]),
|
|
23
53
|
file: configFile.path,
|
|
24
|
-
|
|
54
|
+
// From the match position, not from a text search. Two identical
|
|
55
|
+
// TODOs in one file both reported the first one's line.
|
|
56
|
+
line: this.lineNumberByIndex(match.index, content),
|
|
25
57
|
});
|
|
26
|
-
|
|
27
|
-
|
|
58
|
+
// A zero-length match would otherwise spin here forever. The context
|
|
59
|
+
// is a lookahead, so `lastIndex` sits at the end of the TODO's own
|
|
60
|
+
// line — which is what leaves the lines beneath it open to match.
|
|
61
|
+
if (match.index === pattern.lastIndex) {
|
|
62
|
+
pattern.lastIndex += 1;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
28
65
|
}
|
|
29
66
|
return tasks;
|
|
30
67
|
}
|