@speedkit/cli 4.51.0-run-control.5 → 4.51.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/CHANGELOG.md +37 -0
- package/README.md +14 -1426
- package/dist/commands/diff.d.ts +1 -7
- package/dist/commands/diff.js +3 -9
- package/dist/commands/login.d.ts +0 -3
- package/dist/commands/login.js +3 -14
- package/dist/commands/onboarding.d.ts +0 -26
- package/dist/commands/onboarding.js +4 -221
- package/dist/commands/origin-request.d.ts +0 -4
- package/dist/commands/origin-request.js +0 -4
- package/dist/services/browser-fetch/device-emulation.d.ts +0 -11
- package/dist/services/browser-fetch/device-emulation.js +0 -14
- package/dist/services/bundler/bundle-service-factory.d.ts +3 -0
- package/dist/services/bundler/bundle-service-factory.js +5 -1
- package/dist/services/bundler/bundle-service.d.ts +10 -1
- package/dist/services/bundler/bundle-service.js +16 -1
- package/dist/services/bundler/error/packjockel-error.d.ts +3 -0
- package/dist/services/bundler/error/packjockel-error.js +3 -0
- package/dist/services/bundler/index.d.ts +1 -0
- package/dist/services/bundler/index.js +1 -0
- package/dist/services/bundler/packjockel-service.d.ts +112 -0
- package/dist/services/bundler/packjockel-service.js +202 -0
- package/dist/services/bundler/spec/packjockel-service.spec.js +186 -0
- package/dist/services/cli/cli-environment-factory.d.ts +0 -3
- package/dist/services/cli/cli-environment-factory.js +0 -1
- package/dist/services/cli/cli-service-build-context.d.ts +0 -3
- package/dist/services/cli/cli-service-factory.js +1 -1
- package/dist/services/cli/cli-service-model.d.ts +10 -29
- package/dist/services/cli/cli-service.d.ts +11 -60
- package/dist/services/cli/cli-service.js +32 -196
- package/dist/services/cli/index.d.ts +0 -2
- package/dist/services/cli/index.js +0 -2
- package/dist/services/cli/spec/cli-service.spec.js +50 -113
- package/dist/services/deploy/checks/activation/customer-approval-check.js +1 -1
- package/dist/services/deploy/checks/pre-deploy/device-detection-changed-check.js +2 -3
- package/dist/services/deploy/checks/pre-deploy/split-change-check.js +2 -3
- package/dist/services/deploy/handler/customer-config-handler.d.ts +9 -0
- package/dist/services/deploy/handler/customer-config-handler.js +41 -6
- package/dist/services/deploy/interface/install.d.ts +7 -1
- package/dist/services/deploy/mr/live-state-check.js +21 -2
- package/dist/services/deploy/policy/auto-deploy-policy.js +2 -0
- package/dist/services/deploy/policy/deploy-policy-model.d.ts +4 -0
- package/dist/services/deploy/policy/deploy-policy-model.js +4 -0
- package/dist/services/deploy/policy/testing-deploy-policy.js +2 -0
- package/dist/services/deploy/spec/handler/customer-config-handler.spec.js +98 -0
- package/dist/services/deploy/spec/mr/live-state-check.spec.js +45 -4
- package/dist/services/deploy/spec/policy/auto-deploy-policy.spec.js +2 -0
- package/dist/services/deploy/spec/policy/testing-deploy-policy.spec.js +3 -1
- package/dist/services/diff/diff-service-build-context.d.ts +0 -12
- package/dist/services/diff/diff-service-build-context.js +1 -45
- package/dist/services/diff/diff-service-factory.d.ts +0 -2
- package/dist/services/diff/diff-service-factory.js +25 -65
- package/dist/services/diff/diff-service.d.ts +0 -11
- package/dist/services/diff/diff-service.js +11 -37
- package/dist/services/diff/page-source.d.ts +0 -12
- package/dist/services/diff/page-source.js +11 -16
- package/dist/services/diff/sinks/tool-diff-sink.d.ts +2 -3
- package/dist/services/diff/sinks/tool-diff-sink.js +2 -3
- package/dist/services/diff/spec/diff-service-build-context.spec.js +0 -19
- package/dist/services/diff/spec/diff-service.spec.js +0 -95
- package/dist/services/document-handler-runtime/document-handler-browser-mock.d.ts +13 -0
- package/dist/services/document-handler-runtime/document-handler-browser-mock.js +69 -0
- package/dist/services/document-handler-runtime/document-handler-server.d.ts +27 -0
- package/dist/services/document-handler-runtime/document-handler-server.js +112 -19
- package/dist/services/document-handler-runtime/spec/document-handler-browser-mock.spec.js +34 -0
- package/dist/services/git/git-repository.d.ts +0 -2
- package/dist/services/git/git-repository.js +0 -6
- package/dist/services/integration-api/customer-config-flags.js +0 -1
- package/dist/services/integration-api/integration-api-model.d.ts +4 -1
- package/dist/services/integration-api/spec/customer-config-file.spec.js +56 -0
- package/dist/services/integration-api/spec/speed-kit-config-file.spec.js +68 -8
- package/dist/services/integration-api/struct/customer-config-file.d.ts +15 -0
- package/dist/services/integration-api/struct/customer-config-file.js +42 -0
- package/dist/services/integration-api/struct/customer-config.d.ts +55 -1
- package/dist/services/integration-api/struct/customer-config.js +70 -3
- package/dist/services/integration-api/struct/speed-kit-config-file.d.ts +11 -4
- package/dist/services/integration-api/struct/speed-kit-config-file.js +31 -10
- package/dist/services/onboarding/browse/browse-service.d.ts +1 -13
- package/dist/services/onboarding/browse/browse-service.js +7 -43
- package/dist/services/onboarding/browser/baqend-response.d.ts +1 -17
- package/dist/services/onboarding/browser/baqend-response.js +0 -23
- package/dist/services/onboarding/browser/emulate-device.d.ts +1 -12
- package/dist/services/onboarding/browser/emulate-device.js +13 -68
- package/dist/services/onboarding/browser/executable/executable-validator.js +2 -4
- package/dist/services/onboarding/browser/extension/extension-bridge.js +3 -5
- package/dist/services/onboarding/browser/extension/extension-downloader.js +8 -17
- package/dist/services/onboarding/browser/extension/extension-validator.js +4 -9
- package/dist/services/onboarding/browser/launch-browser.d.ts +1 -2
- package/dist/services/onboarding/browser/launch-browser.js +1 -6
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.d.ts +2 -0
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +29 -8
- package/dist/services/onboarding/dashboard/diff-against-current-page.js +1 -3
- package/dist/services/onboarding/dashboard/index.js +2 -7
- package/dist/services/onboarding/fetch-event-handler.d.ts +5 -24
- package/dist/services/onboarding/fetch-event-handler.js +32 -103
- package/dist/services/onboarding/fetch-events/spec/speed-kit-install-js.spec.js +59 -0
- package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +7 -14
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +0 -14
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +0 -30
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +3 -14
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +10 -29
- package/dist/services/onboarding/file-events/file-watcher.d.ts +4 -43
- package/dist/services/onboarding/file-events/file-watcher.js +21 -119
- package/dist/services/onboarding/inject/inject-service.js +1 -1
- package/dist/services/onboarding/onboarding-model.d.ts +7 -40
- package/dist/services/onboarding/onboarding-model.js +9 -20
- package/dist/services/onboarding/onboarding-service-build-context.d.ts +0 -4
- package/dist/services/onboarding/onboarding-service-build-context.js +1 -7
- package/dist/services/onboarding/onboarding-service-factory.d.ts +1 -17
- package/dist/services/onboarding/onboarding-service-factory.js +35 -152
- package/dist/services/onboarding/onboarding-service.d.ts +1 -40
- package/dist/services/onboarding/onboarding-service.js +23 -139
- package/dist/services/onboarding/request-cache/cache.d.ts +5 -62
- package/dist/services/onboarding/request-cache/cache.js +17 -128
- package/dist/services/onboarding/spec/file-events/file-watcher.spec.js +67 -0
- package/dist/services/onboarding/spec/onboarding-model.spec.js +3 -39
- package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +1 -25
- package/dist/services/onboarding/templates/install-speed-kit-js-template.js +5 -0
- package/dist/services/onboarding/todo-collector.d.ts +2 -7
- package/dist/services/onboarding/todo-collector.js +12 -49
- package/dist/services/onboarding/virtual-orestes-app/index.d.ts +0 -38
- package/dist/services/onboarding/virtual-orestes-app/index.js +27 -113
- package/dist/services/origin-request/asset-variations.d.ts +0 -14
- package/dist/services/origin-request/asset-variations.js +4 -11
- package/dist/services/origin-request/origin-fetcher.d.ts +0 -7
- package/dist/services/origin-request/origin-fetcher.js +5 -43
- package/dist/services/origin-request/origin-request-service-build-context.d.ts +0 -17
- package/dist/services/origin-request/origin-request-service-build-context.js +0 -8
- package/dist/services/origin-request/origin-request-service-factory.d.ts +5 -0
- package/dist/services/origin-request/origin-request-service-factory.js +30 -2
- package/dist/services/origin-request/origin-request-service.d.ts +6 -121
- package/dist/services/origin-request/origin-request-service.js +49 -273
- package/dist/services/origin-request/runtime-config-source.d.ts +0 -6
- package/dist/services/origin-request/runtime-config-source.js +4 -15
- package/dist/services/origin-request/spec/asset-variations.spec.js +0 -20
- package/dist/services/origin-request/spec/origin-request-service.spec.js +6 -329
- package/dist/services/pull/pull-service.js +23 -5
- package/dist/services/query-builder/query-builder-factory.js +3 -3
- package/dist/services/setup/os/tool-registry.js +2 -2
- package/oclif.manifest.json +269 -3390
- package/package.json +3 -20
- package/dist/base/run-control-command.d.ts +0 -15
- package/dist/base/run-control-command.js +0 -20
- package/dist/build-info.json +0 -6
- package/dist/commands/onboarding/browser/click.d.ts +0 -75
- package/dist/commands/onboarding/browser/click.js +0 -19
- package/dist/commands/onboarding/browser/emulate.d.ts +0 -105
- package/dist/commands/onboarding/browser/emulate.js +0 -26
- package/dist/commands/onboarding/browser/navigate.d.ts +0 -75
- package/dist/commands/onboarding/browser/navigate.js +0 -19
- package/dist/commands/onboarding/browser/panel.d.ts +0 -63
- package/dist/commands/onboarding/browser/panel.js +0 -12
- package/dist/commands/onboarding/browser/reinstall-sw.d.ts +0 -63
- package/dist/commands/onboarding/browser/reinstall-sw.js +0 -14
- package/dist/commands/onboarding/browser/reset.d.ts +0 -71
- package/dist/commands/onboarding/browser/reset.js +0 -18
- package/dist/commands/onboarding/browser/screenshot.d.ts +0 -77
- package/dist/commands/onboarding/browser/screenshot.js +0 -19
- package/dist/commands/onboarding/browser/state.d.ts +0 -63
- package/dist/commands/onboarding/browser/state.js +0 -12
- package/dist/commands/onboarding/browser/tabs.d.ts +0 -58
- package/dist/commands/onboarding/browser/tabs.js +0 -16
- package/dist/commands/onboarding/cache/clear.d.ts +0 -58
- package/dist/commands/onboarding/cache/clear.js +0 -12
- package/dist/commands/onboarding/cache/errors.d.ts +0 -58
- package/dist/commands/onboarding/cache/errors.js +0 -12
- package/dist/commands/onboarding/cache/evict.d.ts +0 -62
- package/dist/commands/onboarding/cache/evict.js +0 -15
- package/dist/commands/onboarding/cache/get.d.ts +0 -85
- package/dist/commands/onboarding/cache/get.js +0 -17
- package/dist/commands/onboarding/cache/list.d.ts +0 -58
- package/dist/commands/onboarding/cache/list.js +0 -15
- package/dist/commands/onboarding/cache/prewarm.d.ts +0 -73
- package/dist/commands/onboarding/cache/prewarm.js +0 -20
- package/dist/commands/onboarding/cache/refresh.d.ts +0 -62
- package/dist/commands/onboarding/cache/refresh.js +0 -18
- package/dist/commands/onboarding/cdp.d.ts +0 -81
- package/dist/commands/onboarding/cdp.js +0 -18
- package/dist/commands/onboarding/debug/arm.d.ts +0 -83
- package/dist/commands/onboarding/debug/arm.js +0 -19
- package/dist/commands/onboarding/debug/await.d.ts +0 -71
- package/dist/commands/onboarding/debug/await.js +0 -18
- package/dist/commands/onboarding/debug/disarm.d.ts +0 -63
- package/dist/commands/onboarding/debug/disarm.js +0 -12
- package/dist/commands/onboarding/debug/eval.d.ts +0 -75
- package/dist/commands/onboarding/debug/eval.js +0 -16
- package/dist/commands/onboarding/debug/release.d.ts +0 -63
- package/dist/commands/onboarding/debug/release.js +0 -12
- package/dist/commands/onboarding/debug/resume.d.ts +0 -63
- package/dist/commands/onboarding/debug/resume.js +0 -12
- package/dist/commands/onboarding/debug/status.d.ts +0 -63
- package/dist/commands/onboarding/debug/status.js +0 -12
- package/dist/commands/onboarding/debug/step.d.ts +0 -67
- package/dist/commands/onboarding/debug/step.js +0 -15
- package/dist/commands/onboarding/files/list.d.ts +0 -58
- package/dist/commands/onboarding/files/list.js +0 -12
- package/dist/commands/onboarding/files/read.d.ts +0 -73
- package/dist/commands/onboarding/files/read.js +0 -16
- package/dist/commands/onboarding/files/rebuild.d.ts +0 -63
- package/dist/commands/onboarding/files/rebuild.js +0 -18
- package/dist/commands/onboarding/files/validate.d.ts +0 -58
- package/dist/commands/onboarding/files/validate.js +0 -12
- package/dist/commands/onboarding/fouc.d.ts +0 -77
- package/dist/commands/onboarding/fouc.js +0 -16
- package/dist/commands/onboarding/inject/add.d.ts +0 -89
- package/dist/commands/onboarding/inject/add.js +0 -17
- package/dist/commands/onboarding/inject/clear.d.ts +0 -63
- package/dist/commands/onboarding/inject/clear.js +0 -12
- package/dist/commands/onboarding/inject/list.d.ts +0 -63
- package/dist/commands/onboarding/inject/list.js +0 -12
- package/dist/commands/onboarding/inject/read.d.ts +0 -75
- package/dist/commands/onboarding/inject/read.js +0 -18
- package/dist/commands/onboarding/inject/recipes.d.ts +0 -63
- package/dist/commands/onboarding/inject/recipes.js +0 -12
- package/dist/commands/onboarding/inject/remove.d.ts +0 -67
- package/dist/commands/onboarding/inject/remove.js +0 -15
- package/dist/commands/onboarding/list.d.ts +0 -13
- package/dist/commands/onboarding/list.js +0 -12
- package/dist/commands/onboarding/logs.d.ts +0 -41
- package/dist/commands/onboarding/logs.js +0 -257
- package/dist/commands/onboarding/navwalk.d.ts +0 -95
- package/dist/commands/onboarding/navwalk.js +0 -19
- package/dist/commands/onboarding/response.d.ts +0 -67
- package/dist/commands/onboarding/response.js +0 -18
- package/dist/commands/onboarding/rum/beacons.d.ts +0 -75
- package/dist/commands/onboarding/rum/beacons.js +0 -16
- package/dist/commands/onboarding/rum/get.d.ts +0 -77
- package/dist/commands/onboarding/rum/get.js +0 -18
- package/dist/commands/onboarding/rum/key.d.ts +0 -67
- package/dist/commands/onboarding/rum/key.js +0 -13
- package/dist/commands/onboarding/rum/previous.d.ts +0 -63
- package/dist/commands/onboarding/rum/previous.js +0 -12
- package/dist/commands/onboarding/status.d.ts +0 -13
- package/dist/commands/onboarding/status.js +0 -17
- package/dist/commands/onboarding/stop.d.ts +0 -13
- package/dist/commands/onboarding/stop.js +0 -17
- package/dist/commands/onboarding/todo.d.ts +0 -58
- package/dist/commands/onboarding/todo.js +0 -12
- package/dist/commands/onboarding/viewport.d.ts +0 -101
- package/dist/commands/onboarding/viewport.js +0 -18
- package/dist/commands/onboarding/watch.d.ts +0 -93
- package/dist/commands/onboarding/watch.js +0 -16
- package/dist/commands/spec/onboarding.spec.js +0 -127
- package/dist/services/cli/build-info.d.ts +0 -33
- package/dist/services/cli/build-info.js +0 -63
- package/dist/services/cli/sink.d.ts +0 -47
- package/dist/services/cli/sink.js +0 -31
- package/dist/services/cli/spec/build-identity.spec.js +0 -85
- package/dist/services/cli/spec/build-info.spec.js +0 -10
- package/dist/services/cli/spec/cli-service-log.spec.js +0 -133
- package/dist/services/cli/spec/memory-cli.d.ts +0 -9
- package/dist/services/cli/spec/memory-cli.js +0 -9
- package/dist/services/diff/config-at-ref.d.ts +0 -20
- package/dist/services/diff/config-at-ref.js +0 -33
- package/dist/services/diff/run-runtime-config.d.ts +0 -33
- package/dist/services/diff/run-runtime-config.js +0 -74
- package/dist/services/diff/spec/config-at-ref.spec.js +0 -46
- package/dist/services/diff/spec/run-runtime-config.spec.js +0 -87
- package/dist/services/onboarding/browser/answer-dialogs.d.ts +0 -12
- package/dist/services/onboarding/browser/answer-dialogs.js +0 -25
- package/dist/services/onboarding/browser/console-log.d.ts +0 -9
- package/dist/services/onboarding/browser/console-log.js +0 -27
- package/dist/services/onboarding/browser/resume-restarted-workers.d.ts +0 -14
- package/dist/services/onboarding/browser/resume-restarted-workers.js +0 -26
- package/dist/services/onboarding/control/body-inspect.d.ts +0 -24
- package/dist/services/onboarding/control/body-inspect.js +0 -106
- package/dist/services/onboarding/control/browser-session.d.ts +0 -547
- package/dist/services/onboarding/control/browser-session.js +0 -1337
- package/dist/services/onboarding/control/config-validation.d.ts +0 -17
- package/dist/services/onboarding/control/config-validation.js +0 -46
- package/dist/services/onboarding/control/control-protocol.d.ts +0 -1430
- package/dist/services/onboarding/control/control-protocol.js +0 -58
- package/dist/services/onboarding/control/control-server.d.ts +0 -292
- package/dist/services/onboarding/control/control-server.js +0 -1629
- package/dist/services/onboarding/control/debug-session.d.ts +0 -219
- package/dist/services/onboarding/control/debug-session.js +0 -897
- package/dist/services/onboarding/control/fouc.d.ts +0 -23
- package/dist/services/onboarding/control/fouc.js +0 -151
- package/dist/services/onboarding/control/index.d.ts +0 -4
- package/dist/services/onboarding/control/index.js +0 -4
- package/dist/services/onboarding/control/navigate-wait.d.ts +0 -33
- package/dist/services/onboarding/control/navigate-wait.js +0 -56
- package/dist/services/onboarding/control/navwalk.d.ts +0 -65
- package/dist/services/onboarding/control/navwalk.js +0 -248
- package/dist/services/onboarding/control/preload-registry.d.ts +0 -150
- package/dist/services/onboarding/control/preload-registry.js +0 -829
- package/dist/services/onboarding/control/response-explainer.d.ts +0 -24
- package/dist/services/onboarding/control/response-explainer.js +0 -257
- package/dist/services/onboarding/control/rum.d.ts +0 -8
- package/dist/services/onboarding/control/rum.js +0 -220
- package/dist/services/onboarding/control/service-worker-tracker.d.ts +0 -68
- package/dist/services/onboarding/control/service-worker-tracker.js +0 -120
- package/dist/services/onboarding/control/viewport.d.ts +0 -45
- package/dist/services/onboarding/control/viewport.js +0 -344
- package/dist/services/onboarding/control/watch.d.ts +0 -26
- package/dist/services/onboarding/control/watch.js +0 -157
- package/dist/services/onboarding/request-cache/asset-key.d.ts +0 -61
- package/dist/services/onboarding/request-cache/asset-key.js +0 -115
- package/dist/services/onboarding/spec/browser/answer-dialogs.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/browser/answer-dialogs.spec.js +0 -66
- package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/browser/console-log.spec.js +0 -42
- package/dist/services/onboarding/spec/browser/resume-restarted-workers.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/browser/resume-restarted-workers.spec.js +0 -45
- package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/control/browser-session.spec.js +0 -753
- package/dist/services/onboarding/spec/control/control-server.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/control/control-server.spec.js +0 -371
- package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/control/debug-session.spec.js +0 -751
- package/dist/services/onboarding/spec/control/fakes.d.ts +0 -31
- package/dist/services/onboarding/spec/control/fakes.js +0 -67
- package/dist/services/onboarding/spec/control/fouc.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/control/fouc.spec.js +0 -167
- package/dist/services/onboarding/spec/control/navigate-wait.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/control/navigate-wait.spec.js +0 -47
- package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/control/navwalk.spec.js +0 -222
- package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/control/preload-registry.spec.js +0 -432
- package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/control/response-explainer.spec.js +0 -324
- package/dist/services/onboarding/spec/control/rum.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/control/rum.spec.js +0 -222
- package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +0 -193
- package/dist/services/onboarding/spec/control/viewport.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/control/viewport.spec.js +0 -200
- package/dist/services/onboarding/spec/control/watch.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/control/watch.spec.js +0 -187
- package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/fetch-event-handler.spec.js +0 -219
- package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +0 -41
- package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/request-cache/cache.spec.js +0 -107
- package/dist/services/onboarding/spec/todo-collector.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/todo-collector.spec.js +0 -136
- package/dist/services/onboarding/spec/virtual-orestes-app/virtual-orestes-app.spec.d.ts +0 -1
- package/dist/services/onboarding/spec/virtual-orestes-app/virtual-orestes-app.spec.js +0 -65
- package/dist/services/query-builder/rules/rule-match.d.ts +0 -35
- package/dist/services/query-builder/rules/rule-match.js +0 -70
- package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +0 -1
- package/dist/services/query-builder/spec/rules/rule-match.spec.js +0 -121
- package/dist/services/run-control/browser/run-browser-contexts.d.ts +0 -557
- package/dist/services/run-control/browser/run-browser-contexts.js +0 -91
- package/dist/services/run-control/browser/run-browser-service-factory.d.ts +0 -5
- package/dist/services/run-control/browser/run-browser-service-factory.js +0 -7
- package/dist/services/run-control/browser/run-browser-service.d.ts +0 -68
- package/dist/services/run-control/browser/run-browser-service.js +0 -206
- package/dist/services/run-control/cache/run-cache-contexts.d.ts +0 -349
- package/dist/services/run-control/cache/run-cache-contexts.js +0 -51
- package/dist/services/run-control/cache/run-cache-service-factory.d.ts +0 -6
- package/dist/services/run-control/cache/run-cache-service-factory.js +0 -12
- package/dist/services/run-control/cache/run-cache-service.d.ts +0 -35
- package/dist/services/run-control/cache/run-cache-service.js +0 -151
- package/dist/services/run-control/control-client.d.ts +0 -36
- package/dist/services/run-control/control-client.js +0 -147
- package/dist/services/run-control/debug/run-debug-contexts.d.ts +0 -416
- package/dist/services/run-control/debug/run-debug-contexts.js +0 -47
- package/dist/services/run-control/debug/run-debug-service-factory.d.ts +0 -5
- package/dist/services/run-control/debug/run-debug-service-factory.js +0 -7
- package/dist/services/run-control/debug/run-debug-service.d.ts +0 -39
- package/dist/services/run-control/debug/run-debug-service.js +0 -164
- package/dist/services/run-control/files/run-files-contexts.d.ts +0 -238
- package/dist/services/run-control/files/run-files-contexts.js +0 -26
- package/dist/services/run-control/files/run-files-service-factory.d.ts +0 -5
- package/dist/services/run-control/files/run-files-service-factory.js +0 -7
- package/dist/services/run-control/files/run-files-service.d.ts +0 -29
- package/dist/services/run-control/files/run-files-service.js +0 -120
- package/dist/services/run-control/index.d.ts +0 -32
- package/dist/services/run-control/index.js +0 -31
- package/dist/services/run-control/inject/run-inject-contexts.d.ts +0 -319
- package/dist/services/run-control/inject/run-inject-contexts.js +0 -38
- package/dist/services/run-control/inject/run-inject-service-factory.d.ts +0 -5
- package/dist/services/run-control/inject/run-inject-service-factory.js +0 -7
- package/dist/services/run-control/inject/run-inject-service.d.ts +0 -31
- package/dist/services/run-control/inject/run-inject-service.js +0 -227
- package/dist/services/run-control/live-run.d.ts +0 -37
- package/dist/services/run-control/live-run.js +0 -56
- package/dist/services/run-control/probe/run-probe-contexts.d.ts +0 -333
- package/dist/services/run-control/probe/run-probe-contexts.js +0 -73
- package/dist/services/run-control/probe/run-probe-service-factory.d.ts +0 -5
- package/dist/services/run-control/probe/run-probe-service-factory.js +0 -7
- package/dist/services/run-control/probe/run-probe-service.d.ts +0 -54
- package/dist/services/run-control/probe/run-probe-service.js +0 -194
- package/dist/services/run-control/rum/run-rum-contexts.d.ts +0 -216
- package/dist/services/run-control/rum/run-rum-contexts.js +0 -34
- package/dist/services/run-control/rum/run-rum-service-factory.d.ts +0 -5
- package/dist/services/run-control/rum/run-rum-service-factory.js +0 -7
- package/dist/services/run-control/rum/run-rum-service.d.ts +0 -36
- package/dist/services/run-control/rum/run-rum-service.js +0 -122
- package/dist/services/run-control/run-answer.d.ts +0 -28
- package/dist/services/run-control/run-answer.js +0 -58
- package/dist/services/run-control/run-control-context.d.ts +0 -102
- package/dist/services/run-control/run-control-context.js +0 -36
- package/dist/services/run-control/run-control-flags.d.ts +0 -12
- package/dist/services/run-control/run-control-flags.js +0 -22
- package/dist/services/run-control/run-control-model.d.ts +0 -9
- package/dist/services/run-control/run-control-model.js +0 -1
- package/dist/services/run-control/run-control-service-factory.d.ts +0 -14
- package/dist/services/run-control/run-control-service-factory.js +0 -26
- package/dist/services/run-control/session/run-session-contexts.d.ts +0 -25
- package/dist/services/run-control/session/run-session-contexts.js +0 -20
- package/dist/services/run-control/session/run-session-service-factory.d.ts +0 -8
- package/dist/services/run-control/session/run-session-service-factory.js +0 -18
- package/dist/services/run-control/session/run-session-service.d.ts +0 -32
- package/dist/services/run-control/session/run-session-service.js +0 -151
- package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +0 -1
- package/dist/services/run-control/spec/browser/run-browser-service.spec.js +0 -328
- package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +0 -1
- package/dist/services/run-control/spec/cache/run-cache-service.spec.js +0 -454
- package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +0 -1
- package/dist/services/run-control/spec/debug/run-debug-service.spec.js +0 -113
- package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +0 -1
- package/dist/services/run-control/spec/files/run-files-service.spec.js +0 -234
- package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +0 -1
- package/dist/services/run-control/spec/inject/run-inject-service.spec.js +0 -251
- package/dist/services/run-control/spec/live-run-fixture.d.ts +0 -32
- package/dist/services/run-control/spec/live-run-fixture.js +0 -109
- package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +0 -1
- package/dist/services/run-control/spec/probe/run-probe-service.spec.js +0 -108
- package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +0 -1
- package/dist/services/run-control/spec/rum/run-rum-service.spec.js +0 -47
- package/dist/services/run-control/spec/run-answer.spec.d.ts +0 -1
- package/dist/services/run-control/spec/run-answer.spec.js +0 -57
- package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +0 -1
- package/dist/services/run-control/spec/session/run-session-service.spec.js +0 -150
- package/dist/services/run-log/crash-mirror.d.ts +0 -31
- package/dist/services/run-log/crash-mirror.js +0 -69
- package/dist/services/run-log/index.d.ts +0 -11
- package/dist/services/run-log/index.js +0 -11
- package/dist/services/run-log/jsonl-appender.d.ts +0 -46
- package/dist/services/run-log/jsonl-appender.js +0 -91
- package/dist/services/run-log/log-event-model.d.ts +0 -104
- package/dist/services/run-log/log-event-model.js +0 -56
- package/dist/services/run-log/log-query-service-factory.d.ts +0 -11
- package/dist/services/run-log/log-query-service-factory.js +0 -14
- package/dist/services/run-log/log-query-service.d.ts +0 -59
- package/dist/services/run-log/log-query-service.js +0 -111
- package/dist/services/run-log/log-reader.d.ts +0 -84
- package/dist/services/run-log/log-reader.js +0 -180
- package/dist/services/run-log/log-summary.d.ts +0 -72
- package/dist/services/run-log/log-summary.js +0 -208
- package/dist/services/run-log/redaction.d.ts +0 -34
- package/dist/services/run-log/redaction.js +0 -124
- package/dist/services/run-log/request-log.d.ts +0 -82
- package/dist/services/run-log/request-log.js +0 -69
- package/dist/services/run-log/request-summary.d.ts +0 -76
- package/dist/services/run-log/request-summary.js +0 -0
- package/dist/services/run-log/run-log.d.ts +0 -61
- package/dist/services/run-log/run-log.js +0 -102
- package/dist/services/run-log/spec/log-query-service.spec.d.ts +0 -1
- package/dist/services/run-log/spec/log-query-service.spec.js +0 -197
- package/dist/services/run-log/spec/log-reader.spec.d.ts +0 -1
- package/dist/services/run-log/spec/log-reader.spec.js +0 -109
- package/dist/services/run-log/spec/log-summary.spec.d.ts +0 -1
- package/dist/services/run-log/spec/log-summary.spec.js +0 -153
- package/dist/services/run-log/spec/redaction.spec.d.ts +0 -1
- package/dist/services/run-log/spec/redaction.spec.js +0 -61
- package/dist/services/run-log/spec/request-log.spec.d.ts +0 -1
- package/dist/services/run-log/spec/request-log.spec.js +0 -101
- package/dist/services/run-log/spec/request-summary.spec.d.ts +0 -1
- package/dist/services/run-log/spec/request-summary.spec.js +0 -171
- package/dist/services/run-log/spec/run-log.spec.d.ts +0 -1
- package/dist/services/run-log/spec/run-log.spec.js +0 -122
- package/dist/services/run-registry/exit-classification.d.ts +0 -39
- package/dist/services/run-registry/exit-classification.js +0 -42
- package/dist/services/run-registry/index.d.ts +0 -3
- package/dist/services/run-registry/index.js +0 -3
- package/dist/services/run-registry/process-identity.d.ts +0 -28
- package/dist/services/run-registry/process-identity.js +0 -80
- package/dist/services/run-registry/run-registry-model.d.ts +0 -128
- package/dist/services/run-registry/run-registry-model.js +0 -16
- package/dist/services/run-registry/run-registry.d.ts +0 -155
- package/dist/services/run-registry/run-registry.js +0 -430
- package/dist/services/run-registry/spec/exit-classification.spec.d.ts +0 -1
- package/dist/services/run-registry/spec/exit-classification.spec.js +0 -82
- package/dist/services/run-registry/spec/run-registry.spec.d.ts +0 -1
- package/dist/services/run-registry/spec/run-registry.spec.js +0 -526
- /package/dist/{commands/spec/onboarding.spec.d.ts → services/bundler/spec/packjockel-service.spec.d.ts} +0 -0
- /package/dist/services/{cli/spec/build-identity.spec.d.ts → deploy/spec/handler/customer-config-handler.spec.d.ts} +0 -0
- /package/dist/services/{cli/spec/build-info.spec.d.ts → document-handler-runtime/spec/document-handler-browser-mock.spec.d.ts} +0 -0
- /package/dist/services/{cli/spec/cli-service-log.spec.d.ts → integration-api/spec/customer-config-file.spec.d.ts} +0 -0
- /package/dist/services/{diff/spec/config-at-ref.spec.d.ts → onboarding/fetch-events/spec/speed-kit-install-js.spec.d.ts} +0 -0
- /package/dist/services/{diff/spec/run-runtime-config.spec.d.ts → onboarding/spec/file-events/file-watcher.spec.d.ts} +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser mock that the server passes to a document handler, as in
|
|
3
|
+
* `orestes-node/helper/browserMock.js`. The embedded Speed Kit config runs in
|
|
4
|
+
* it, so a read such as `location.hostname` in `getCurrentHostConfig()` works.
|
|
5
|
+
* `location` points at the app domain, and `window` and `top` are the mock
|
|
6
|
+
* itself. It has no timers and no event listeners, like the server's mock.
|
|
7
|
+
*
|
|
8
|
+
* @param app the app whose domain `location` points to
|
|
9
|
+
* @returns the browser globals by name
|
|
10
|
+
*/
|
|
11
|
+
export function createBrowserGlobals(app) {
|
|
12
|
+
const url = new URL(`https://${app}.app.baqend.com/`);
|
|
13
|
+
const location = {
|
|
14
|
+
href: url.href,
|
|
15
|
+
origin: url.origin,
|
|
16
|
+
protocol: url.protocol,
|
|
17
|
+
host: url.host,
|
|
18
|
+
hostname: url.hostname,
|
|
19
|
+
port: url.port,
|
|
20
|
+
pathname: url.pathname,
|
|
21
|
+
search: url.search,
|
|
22
|
+
hash: url.hash,
|
|
23
|
+
toString: () => url.href,
|
|
24
|
+
};
|
|
25
|
+
const noop = () => {
|
|
26
|
+
/* empty */
|
|
27
|
+
};
|
|
28
|
+
const document = {
|
|
29
|
+
cookie: "",
|
|
30
|
+
referrer: "",
|
|
31
|
+
getElementById: () => null,
|
|
32
|
+
querySelector: () => null,
|
|
33
|
+
querySelectorAll: () => [],
|
|
34
|
+
createElement: noop,
|
|
35
|
+
};
|
|
36
|
+
document.head = document;
|
|
37
|
+
document.body = document;
|
|
38
|
+
const browserGlobals = {
|
|
39
|
+
location,
|
|
40
|
+
APP: app,
|
|
41
|
+
speedKit: {
|
|
42
|
+
split: undefined,
|
|
43
|
+
splitTestId: undefined,
|
|
44
|
+
detectDevice: noop,
|
|
45
|
+
customVariation: [],
|
|
46
|
+
},
|
|
47
|
+
serviceWorkerUrl: "",
|
|
48
|
+
screen: { width: 0, height: 0 },
|
|
49
|
+
devicePixelRatio: 1,
|
|
50
|
+
navigator: {
|
|
51
|
+
userAgent: "",
|
|
52
|
+
connection: {},
|
|
53
|
+
cookieEnabled: false,
|
|
54
|
+
languages: [],
|
|
55
|
+
online: true,
|
|
56
|
+
},
|
|
57
|
+
document,
|
|
58
|
+
localStorage: { getItem: noop, setItem: noop },
|
|
59
|
+
};
|
|
60
|
+
browserGlobals.window = browserGlobals;
|
|
61
|
+
browserGlobals.top = browserGlobals;
|
|
62
|
+
return browserGlobals;
|
|
63
|
+
}
|
|
64
|
+
const BROWSER_GLOBALS = Object.keys(createBrowserGlobals("local"));
|
|
65
|
+
/** The browser global that `error` reports as not defined, or undefined for any other error. */
|
|
66
|
+
export function missingBrowserGlobal(error) {
|
|
67
|
+
const name = /^(\S+) is not defined$/.exec(error?.message ?? "")?.[1];
|
|
68
|
+
return name && BROWSER_GLOBALS.includes(name) ? name : undefined;
|
|
69
|
+
}
|
|
@@ -13,6 +13,11 @@ export declare class DocumentHandlerServer {
|
|
|
13
13
|
private entityManager?;
|
|
14
14
|
private documentHandlerCode;
|
|
15
15
|
private documentHandlerConfigCode;
|
|
16
|
+
/**
|
|
17
|
+
* The packjockel bundle for a customer with the `enableSpeedKitConfigPlugins` feature: the handler, its config
|
|
18
|
+
* and the Speed Kit config in one CommonJS module, which exports `post`.
|
|
19
|
+
*/
|
|
20
|
+
private documentHandlerBundle?;
|
|
16
21
|
private database;
|
|
17
22
|
/** Sources of app modules already looked up; `null` marks a lookup that came back empty. */
|
|
18
23
|
private readonly appModules;
|
|
@@ -22,11 +27,33 @@ export declare class DocumentHandlerServer {
|
|
|
22
27
|
*/
|
|
23
28
|
constructor(customerConfig: CustomerConfig, files: FileListInterface, bundler: BundleService, cli: CliServiceInterface, workSpace: string, verboseLevel?: boolean, entityManager?: EntityManager);
|
|
24
29
|
transform(contentType: string, html: string, variation: string, url: string, headers: Record<string, string>): Promise<DocumentHandlerResponse>;
|
|
30
|
+
/** Runs the handler in the context, and returns the config, which calls its `post`. */
|
|
31
|
+
private createScript;
|
|
32
|
+
/**
|
|
33
|
+
* Loads the packjockel bundle like a CommonJS module, and calls the `post` it exports. The browser mock
|
|
34
|
+
* shadows the globals of the bundle, as on the server.
|
|
35
|
+
*/
|
|
36
|
+
private createBundleScript;
|
|
37
|
+
/**
|
|
38
|
+
* Loads the bundle once without the browser mock. The service worker embeds the config without a browser
|
|
39
|
+
* around it, so the server's proof rejects a config that reads a browser global while it loads.
|
|
40
|
+
*
|
|
41
|
+
* @returns the browser global the config reads, or undefined
|
|
42
|
+
*/
|
|
43
|
+
private findBrowserGlobalRead;
|
|
44
|
+
private getDocumentHandlerConfigPath;
|
|
25
45
|
private getTransformFunctionWrapper;
|
|
26
46
|
buildDocumentHandler(): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Bundles the handler, its config and the Speed Kit config into one module, the way the server
|
|
49
|
+
* deploys a customer with the `enableSpeedKitConfigPlugins` feature.
|
|
50
|
+
*/
|
|
51
|
+
private bundleWithPackjockel;
|
|
27
52
|
private deactivateReleaseAndDeploymentDetection;
|
|
28
53
|
private getDocumentHandler;
|
|
29
54
|
private getDynamicFetcher;
|
|
55
|
+
/** The customer's own dynamic fetcher, or else the source of the latest one. */
|
|
56
|
+
private getDynamicFetcherSource;
|
|
30
57
|
private getDynamicFetcherConfig;
|
|
31
58
|
private getStyles;
|
|
32
59
|
private getDocumentHandlerConfig;
|
|
@@ -2,11 +2,13 @@ import { LATEST_DYNAMIC_FETCHER_URL, LOCAL_DOCUMENT_HANDLER, LOCAL_DOCUMENT_HAND
|
|
|
2
2
|
import RequiredFileNotFoundError from "./error/required-file-not-found-error.js";
|
|
3
3
|
import DatabaseMock from "./templates/database-mock.js";
|
|
4
4
|
import * as vm from "node:vm";
|
|
5
|
+
import { embedsConfigInServiceWorker, usesConfigPlugins, } from "../integration-api/index.js";
|
|
5
6
|
import { INTEGRATION_FILES } from "../../models/files.js";
|
|
6
7
|
// documentHandlerDependencies
|
|
7
8
|
import fetch from "node-fetch";
|
|
8
9
|
import { Request } from "./server/request.js";
|
|
9
10
|
import { DocumentHandlerResponse } from "./server/document-handler-response.js";
|
|
11
|
+
import { createBrowserGlobals, missingBrowserGlobal, } from "./document-handler-browser-mock.js";
|
|
10
12
|
import { DocumentHandlerAbort } from "./document-handler-abort.js";
|
|
11
13
|
import { DocumentHandlerConsole } from "./document-handler-console.js";
|
|
12
14
|
import { safe } from "../../helpers/safe.js";
|
|
@@ -25,6 +27,11 @@ export class DocumentHandlerServer {
|
|
|
25
27
|
entityManager;
|
|
26
28
|
documentHandlerCode;
|
|
27
29
|
documentHandlerConfigCode;
|
|
30
|
+
/**
|
|
31
|
+
* The packjockel bundle for a customer with the `enableSpeedKitConfigPlugins` feature: the handler, its config
|
|
32
|
+
* and the Speed Kit config in one CommonJS module, which exports `post`.
|
|
33
|
+
*/
|
|
34
|
+
documentHandlerBundle;
|
|
28
35
|
database;
|
|
29
36
|
/** Sources of app modules already looked up; `null` marks a lookup that came back empty. */
|
|
30
37
|
appModules = new Map();
|
|
@@ -42,7 +49,11 @@ export class DocumentHandlerServer {
|
|
|
42
49
|
this.entityManager = entityManager;
|
|
43
50
|
}
|
|
44
51
|
async transform(contentType, html, variation, url, headers) {
|
|
45
|
-
|
|
52
|
+
const configPlugins = usesConfigPlugins(this.customerConfig);
|
|
53
|
+
const built = configPlugins
|
|
54
|
+
? this.documentHandlerBundle
|
|
55
|
+
: this.documentHandlerCode && this.documentHandlerConfigCode;
|
|
56
|
+
if (!built) {
|
|
46
57
|
await this.buildDocumentHandler();
|
|
47
58
|
}
|
|
48
59
|
const skInternalRequest = new Request(url, html, variation, headers, {
|
|
@@ -57,26 +68,24 @@ export class DocumentHandlerServer {
|
|
|
57
68
|
skInternalError: {},
|
|
58
69
|
Abort: DocumentHandlerAbort,
|
|
59
70
|
APP: this.customerConfig.app,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
// packjockel defines these in the bundle itself.
|
|
72
|
+
...(configPlugins
|
|
73
|
+
? {
|
|
74
|
+
// A fresh mock per request, so that one transform sees no state of the last one.
|
|
75
|
+
skBrowserGlobals: createBrowserGlobals(this.customerConfig.app),
|
|
76
|
+
}
|
|
77
|
+
: {
|
|
78
|
+
DYNAMIC_FETCHER: await this.getDynamicFetcher(),
|
|
79
|
+
DYNAMIC_FETCHER_CONFIG: await this.getDynamicFetcherConfig(),
|
|
80
|
+
CUSTOM_STYLES: this.getStyles(),
|
|
81
|
+
}),
|
|
63
82
|
...this.getContextVars(),
|
|
64
83
|
...this.createNodeVmContext(),
|
|
65
84
|
skErrorContext: {},
|
|
66
85
|
};
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
filename: customDocumentHandlerFile.path,
|
|
71
|
-
displayErrors: true,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
vm.runInNewContext(this.documentHandlerCode, vmContext);
|
|
76
|
-
}
|
|
77
|
-
const script = new vm.Script(this.documentHandlerConfigCode + this.getTransformFunctionWrapper(), {
|
|
78
|
-
filename: this.files.getByName("config_documentHandler").path,
|
|
79
|
-
});
|
|
86
|
+
const script = configPlugins
|
|
87
|
+
? this.createBundleScript()
|
|
88
|
+
: this.createScript(vmContext);
|
|
80
89
|
const vmResponse = await safe(new Promise((resolve, reject) => {
|
|
81
90
|
vmContext.skInternalResponse.resolve = resolve;
|
|
82
91
|
// @ts-expect-error reject is unknown
|
|
@@ -92,17 +101,94 @@ export class DocumentHandlerServer {
|
|
|
92
101
|
}
|
|
93
102
|
throw new DocumentHandlerTransformError(vmResponse.errorObj);
|
|
94
103
|
}
|
|
104
|
+
/** Runs the handler in the context, and returns the config, which calls its `post`. */
|
|
105
|
+
createScript(vmContext) {
|
|
106
|
+
const customDocumentHandlerFile = this.files.getByName(INTEGRATION_FILES.CUSTOM.DOCUMENT_HANDLER);
|
|
107
|
+
if (customDocumentHandlerFile.path) {
|
|
108
|
+
vm.runInNewContext(this.documentHandlerCode, vmContext, {
|
|
109
|
+
filename: customDocumentHandlerFile.path,
|
|
110
|
+
displayErrors: true,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
vm.runInNewContext(this.documentHandlerCode, vmContext);
|
|
115
|
+
}
|
|
116
|
+
return new vm.Script(this.documentHandlerConfigCode + this.getTransformFunctionWrapper(), { filename: this.getDocumentHandlerConfigPath() });
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Loads the packjockel bundle like a CommonJS module, and calls the `post` it exports. The browser mock
|
|
120
|
+
* shadows the globals of the bundle, as on the server.
|
|
121
|
+
*/
|
|
122
|
+
createBundleScript() {
|
|
123
|
+
const names = Object.keys(createBrowserGlobals(this.customerConfig.app));
|
|
124
|
+
return new vm.Script(`(function (module, exports, ${names.join(", ")}) {\n${this.documentHandlerBundle}\n})(module, module.exports, ${names.map((name) => `skBrowserGlobals.${name}`).join(", ")});\n\n` +
|
|
125
|
+
`module.exports.post(db, skInternalRequest, skInternalResponse).catch((error)=>reject(error));`, { filename: this.getDocumentHandlerConfigPath() });
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Loads the bundle once without the browser mock. The service worker embeds the config without a browser
|
|
129
|
+
* around it, so the server's proof rejects a config that reads a browser global while it loads.
|
|
130
|
+
*
|
|
131
|
+
* @returns the browser global the config reads, or undefined
|
|
132
|
+
*/
|
|
133
|
+
findBrowserGlobalRead() {
|
|
134
|
+
const loaded = safe(() => vm.runInNewContext(this.documentHandlerBundle, {
|
|
135
|
+
APP: this.customerConfig.app,
|
|
136
|
+
...this.getContextVars(),
|
|
137
|
+
...this.createNodeVmContext(),
|
|
138
|
+
}, { filename: this.getDocumentHandlerConfigPath() }));
|
|
139
|
+
return loaded.success === true
|
|
140
|
+
? undefined
|
|
141
|
+
: missingBrowserGlobal(loaded.errorObj);
|
|
142
|
+
}
|
|
143
|
+
getDocumentHandlerConfigPath() {
|
|
144
|
+
return this.files.getByName("config_documentHandler")
|
|
145
|
+
.path;
|
|
146
|
+
}
|
|
95
147
|
getTransformFunctionWrapper() {
|
|
96
148
|
return `\n\npost(db, skInternalRequest, skInternalResponse).catch((error)=>reject(error));`;
|
|
97
149
|
}
|
|
98
150
|
async buildDocumentHandler() {
|
|
99
151
|
this.cli.startAction("DOCUMENTHANDLER:BUILD", "rebuild documentHandler");
|
|
152
|
+
if (usesConfigPlugins(this.customerConfig)) {
|
|
153
|
+
this.documentHandlerBundle = await this.bundleWithPackjockel();
|
|
154
|
+
const read = embedsConfigInServiceWorker(this.customerConfig)
|
|
155
|
+
? this.findBrowserGlobalRead()
|
|
156
|
+
: undefined;
|
|
157
|
+
if (read) {
|
|
158
|
+
this.cli.failAction("DOCUMENTHANDLER:BUILD", `embeddedConfig: the Speed Kit config reads "${read}" while it loads, so the server rejects it. Read it in a callback, or turn embeddedConfig off.`);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
this.cli.successAction("DOCUMENTHANDLER:BUILD");
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
100
164
|
this.documentHandlerCode = await this.bundleDocumentHandlerCode("custom_documentHandler.js", await this.getDocumentHandler());
|
|
101
165
|
this.documentHandlerConfigCode = await this.bundleDocumentHandlerCode("config_documentHandler.js", this.deactivateReleaseAndDeploymentDetection());
|
|
102
166
|
this.cli.successAction("DOCUMENTHANDLER:BUILD");
|
|
103
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Bundles the handler, its config and the Speed Kit config into one module, the way the server
|
|
170
|
+
* deploys a customer with the `enableSpeedKitConfigPlugins` feature.
|
|
171
|
+
*/
|
|
172
|
+
async bundleWithPackjockel() {
|
|
173
|
+
const customDocumentHandler = this.files.getByName(INTEGRATION_FILES.CUSTOM.DOCUMENT_HANDLER);
|
|
174
|
+
return this.bundler.packjockel.bundleDocumentHandler({
|
|
175
|
+
// Without a custom one, packjockel bundles the published handler of documentHandlerVersion.
|
|
176
|
+
documentHandler: customDocumentHandler?.path
|
|
177
|
+
? await this.getDocumentHandler()
|
|
178
|
+
: undefined,
|
|
179
|
+
documentHandlerConfig: this.deactivateReleaseAndDeploymentDetection(),
|
|
180
|
+
speedKitConfig: this.files
|
|
181
|
+
.getByName(INTEGRATION_FILES.CONFIG.SPEED_KIT)
|
|
182
|
+
.getContent(),
|
|
183
|
+
appName: this.customerConfig.app,
|
|
184
|
+
dynamicFetcher: await this.getDynamicFetcherSource(),
|
|
185
|
+
dynamicFetcherConfig: await this.getDynamicFetcherConfig(),
|
|
186
|
+
customStyle: this.getStyles(),
|
|
187
|
+
versions: this.customerConfig,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
104
190
|
deactivateReleaseAndDeploymentDetection() {
|
|
105
|
-
return this.getDocumentHandlerConfig().replace(
|
|
191
|
+
return this.getDocumentHandlerConfig().replace(/const documentHandler =|export default new /, (selected) => {
|
|
106
192
|
return (`config["executeDeploymentDetection"] = false;config["executeReleaseDetection"] = false;\n` +
|
|
107
193
|
selected);
|
|
108
194
|
});
|
|
@@ -113,10 +199,17 @@ export class DocumentHandlerServer {
|
|
|
113
199
|
.getContent();
|
|
114
200
|
}
|
|
115
201
|
async getDynamicFetcher() {
|
|
202
|
+
if (!this.files.hasFile(LOCAL_DYNAMIC_FETCHER)) {
|
|
203
|
+
return await this.bundleDynamicFetcher({ "dynamic-fetcher": "https://www.baqend.com/speed-kit/latest/" }, await this.getDynamicFetcherSource());
|
|
204
|
+
}
|
|
205
|
+
return this.getDynamicFetcherSource();
|
|
206
|
+
}
|
|
207
|
+
/** The customer's own dynamic fetcher, or else the source of the latest one. */
|
|
208
|
+
async getDynamicFetcherSource() {
|
|
116
209
|
// todo use fetchRemoteFile from integration api
|
|
117
210
|
if (!this.files.hasFile(LOCAL_DYNAMIC_FETCHER)) {
|
|
118
211
|
const response = await fetch(LATEST_DYNAMIC_FETCHER_URL);
|
|
119
|
-
return await
|
|
212
|
+
return await response.text();
|
|
120
213
|
}
|
|
121
214
|
return this.files
|
|
122
215
|
.getByName(INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
|
+
import vm from "node:vm";
|
|
4
|
+
import { createBrowserGlobals, missingBrowserGlobal, } from "../document-handler-browser-mock.js";
|
|
5
|
+
describe("createBrowserGlobals", () => {
|
|
6
|
+
it("should let a config read location.hostname, like the server", () => {
|
|
7
|
+
const globals = createBrowserGlobals("shop");
|
|
8
|
+
const names = Object.keys(globals);
|
|
9
|
+
const read = vm.compileFunction("return [location.hostname, window.location === location, top === window, typeof setTimeout];", names);
|
|
10
|
+
expect(read(...names.map((name) => globals[name]))).to.deep.equal([
|
|
11
|
+
"shop.app.baqend.com",
|
|
12
|
+
true,
|
|
13
|
+
true,
|
|
14
|
+
// The mock shadows no timer: the document handler keeps the real one of Node.js.
|
|
15
|
+
"function",
|
|
16
|
+
]);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe("missingBrowserGlobal", () => {
|
|
20
|
+
it("should name a browser global that a config reads without the mock", () => {
|
|
21
|
+
const read = (code) => {
|
|
22
|
+
try {
|
|
23
|
+
vm.runInNewContext(code, {});
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
return missingBrowserGlobal(error);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
expect(read("location.hostname")).to.equal("location");
|
|
30
|
+
// Only a browser global makes a config not embeddable.
|
|
31
|
+
expect(read("db.find()")).to.equal(undefined);
|
|
32
|
+
expect(read("var x = 1;")).to.equal(undefined);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -24,8 +24,6 @@ export declare class GitRepository {
|
|
|
24
24
|
changedPaths(request: MergedRequest): string[];
|
|
25
25
|
/** The paths below `directory` that the commit holds. */
|
|
26
26
|
pathsAt(sha: string, directory: string): string[];
|
|
27
|
-
/** The commit where HEAD left `ref`: `ref` itself when HEAD contains it. */
|
|
28
|
-
mergeBase(ref: string): string;
|
|
29
27
|
/** The content of one file in the commit. */
|
|
30
28
|
contentAt(sha: string, filePath: string): string;
|
|
31
29
|
/** The paths below `directory` that changed between the commit and HEAD. */
|
|
@@ -77,10 +77,6 @@ export class GitRepository {
|
|
|
77
77
|
.split("\n")
|
|
78
78
|
.filter((line) => line.length > 0);
|
|
79
79
|
}
|
|
80
|
-
/** The commit where HEAD left `ref`: `ref` itself when HEAD contains it. */
|
|
81
|
-
mergeBase(ref) {
|
|
82
|
-
return this.run(["merge-base", "HEAD", ref]).trim();
|
|
83
|
-
}
|
|
84
80
|
/** The content of one file in the commit. */
|
|
85
81
|
contentAt(sha, filePath) {
|
|
86
82
|
return this.run(["show", `${sha}:${filePath}`]);
|
|
@@ -115,8 +111,6 @@ function runGit(cwd) {
|
|
|
115
111
|
cwd,
|
|
116
112
|
encoding: "utf8",
|
|
117
113
|
maxBuffer: 32 * 1024 * 1024,
|
|
118
|
-
// The error below carries git's stderr; inherited, it would print twice.
|
|
119
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
120
114
|
});
|
|
121
115
|
}
|
|
122
116
|
catch (error) {
|
|
@@ -13,6 +13,7 @@ export * from "./virtual/external-recipe.js";
|
|
|
13
13
|
export * from "./virtual/static-recipe.js";
|
|
14
14
|
export * from "./external/external-file-reader.js";
|
|
15
15
|
import type { SpeedKitConfig } from "./struct/speed-kit-config.js";
|
|
16
|
+
import type { SpeedKitConfigCustomer } from "./struct/speed-kit-config-file.js";
|
|
16
17
|
import { CustomerConfig } from "./struct/customer-config.js";
|
|
17
18
|
import { RoFile } from "./struct/ro-file.js";
|
|
18
19
|
import { VirtualFile } from "./struct/virtual-file.js";
|
|
@@ -89,11 +90,13 @@ export interface InstallResourceInterface extends ConfigFileInterface, FileInter
|
|
|
89
90
|
readonly remoteKey: string;
|
|
90
91
|
}
|
|
91
92
|
export interface SpeedKitConfigInterface extends InstallResourceInterface {
|
|
92
|
-
evaluate(
|
|
93
|
+
evaluate(customer: SpeedKitConfigCustomer, origin: string): Promise<SpeedKitConfig>;
|
|
93
94
|
}
|
|
94
95
|
export interface CustomerConfigInterface extends ConfigFileInterface {
|
|
95
96
|
config: CustomerConfig;
|
|
96
97
|
updateOrigins(origins: string[]): void;
|
|
98
|
+
updateFeatures(live?: Record<string, unknown>): boolean;
|
|
99
|
+
updateVersions(live: Record<string, unknown>): boolean;
|
|
97
100
|
readonly configName: string;
|
|
98
101
|
}
|
|
99
102
|
export interface VirtualFileRecipe {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
|
+
import { CustomerConfig, CustomerConfigFile, } from "../../integration-api/index.js";
|
|
4
|
+
function fileWith(production) {
|
|
5
|
+
const content = JSON.stringify({ production }, null, 2);
|
|
6
|
+
return new CustomerConfigFile("config_customer.json", "config_customer.json", content, CustomerConfig.createFrom(production, "production"), "production");
|
|
7
|
+
}
|
|
8
|
+
const BASE = {
|
|
9
|
+
app: "example-shop",
|
|
10
|
+
domain: "production",
|
|
11
|
+
origins: ["https://www.example.com"],
|
|
12
|
+
swPath: "/sw.js",
|
|
13
|
+
scope: "/",
|
|
14
|
+
};
|
|
15
|
+
describe("CustomerConfigFile.updateFeatures", () => {
|
|
16
|
+
it("takes over the features the installation sets", () => {
|
|
17
|
+
const file = fileWith({ ...BASE, features: { embeddedConfig: false } });
|
|
18
|
+
const changed = file.updateFeatures({
|
|
19
|
+
embeddedConfig: true,
|
|
20
|
+
prefetchingOnDeploymentJob: null,
|
|
21
|
+
});
|
|
22
|
+
expect(changed).to.equal(true);
|
|
23
|
+
expect(JSON.parse(file.getContent()).production.features).to.deep.equal({
|
|
24
|
+
embeddedConfig: true,
|
|
25
|
+
});
|
|
26
|
+
expect(file.config.features).to.deep.equal({ embeddedConfig: true });
|
|
27
|
+
});
|
|
28
|
+
it("drops the features when the installation sets none", () => {
|
|
29
|
+
const file = fileWith({ ...BASE, features: { embeddedConfig: true } });
|
|
30
|
+
expect(file.updateFeatures({ embeddedConfig: null })).to.equal(true);
|
|
31
|
+
expect(JSON.parse(file.getContent()).production).to.not.have.property("features");
|
|
32
|
+
});
|
|
33
|
+
it("leaves an equal file alone", () => {
|
|
34
|
+
const file = fileWith({ ...BASE, features: { embeddedConfig: true } });
|
|
35
|
+
const before = file.getContent();
|
|
36
|
+
expect(file.updateFeatures({ embeddedConfig: true })).to.equal(false);
|
|
37
|
+
expect(file.getContent()).to.equal(before);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
describe("CustomerConfigFile.updateVersions", () => {
|
|
41
|
+
it("writes the tags of the installation and drops the ones at latest", () => {
|
|
42
|
+
const file = fileWith({ ...BASE, ppVersion: "1.2.0" });
|
|
43
|
+
const changed = file.updateVersions({
|
|
44
|
+
speedKitVersion: "2.22.4",
|
|
45
|
+
rumPluginsVersion: null,
|
|
46
|
+
ppVersion: null,
|
|
47
|
+
configPluginsVersion: null,
|
|
48
|
+
documentHandlerVersion: null,
|
|
49
|
+
});
|
|
50
|
+
const production = JSON.parse(file.getContent()).production;
|
|
51
|
+
expect(changed).to.equal(true);
|
|
52
|
+
expect(production.speedKitVersion).to.equal("2.22.4");
|
|
53
|
+
expect(production).to.not.have.property("ppVersion");
|
|
54
|
+
expect(file.config.speedKitVersion).to.equal("2.22.4");
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -2,8 +2,21 @@ import { expect } from "chai";
|
|
|
2
2
|
import { describe, it } from "mocha";
|
|
3
3
|
import { SpeedKitConfigFile, VirtualSpeedKitConfigFile } from "../index.js";
|
|
4
4
|
import { INTEGRATION_FILES } from "../../../models/files.js";
|
|
5
|
-
import { BundleServiceFactory } from "../../bundler/index.js";
|
|
5
|
+
import { BundleService, BundleServiceFactory, } from "../../bundler/index.js";
|
|
6
6
|
const bundler = new BundleServiceFactory("./").buildService();
|
|
7
|
+
const SHOP_DE = { app: "shop-de" };
|
|
8
|
+
/** Answers every bundle request with one bundle and keeps the requests. */
|
|
9
|
+
class FakePackjockel {
|
|
10
|
+
bundled;
|
|
11
|
+
requests = [];
|
|
12
|
+
constructor(bundled) {
|
|
13
|
+
this.bundled = bundled;
|
|
14
|
+
}
|
|
15
|
+
async bundle(request) {
|
|
16
|
+
this.requests.push(request);
|
|
17
|
+
return this.bundled;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
7
20
|
function configFile(source) {
|
|
8
21
|
return new SpeedKitConfigFile({
|
|
9
22
|
name: INTEGRATION_FILES.CONFIG.SPEED_KIT,
|
|
@@ -13,7 +26,7 @@ function configFile(source) {
|
|
|
13
26
|
}, bundler);
|
|
14
27
|
}
|
|
15
28
|
function evaluate(source) {
|
|
16
|
-
return configFile(source).evaluate(
|
|
29
|
+
return configFile(source).evaluate(SHOP_DE, "https://www.shop.de");
|
|
17
30
|
}
|
|
18
31
|
/** What the config assigned, for the tests about the browser mock itself. */
|
|
19
32
|
async function evaluateRaw(source) {
|
|
@@ -89,19 +102,19 @@ describe("SpeedKitConfigFile", () => {
|
|
|
89
102
|
// builder and the pre-deploy checks both go through here.
|
|
90
103
|
const file = configFile(`window.speedKit = { host: window.location.host };`);
|
|
91
104
|
const [first, second] = await Promise.all([
|
|
92
|
-
file.evaluate(
|
|
93
|
-
file.evaluate(
|
|
105
|
+
file.evaluate(SHOP_DE, "https://www.shop.de"),
|
|
106
|
+
file.evaluate(SHOP_DE, "https://www.shop.de"),
|
|
94
107
|
]);
|
|
95
|
-
const otherOrigin = await file.evaluate(
|
|
108
|
+
const otherOrigin = await file.evaluate(SHOP_DE, "https://m.shop.de");
|
|
96
109
|
expect(first).to.equal(second);
|
|
97
110
|
expect(otherOrigin).to.not.equal(first);
|
|
98
111
|
expect(otherOrigin.raw.host).to.equal("m.shop.de");
|
|
99
112
|
});
|
|
100
113
|
it("should forget what it read when the file changes", async () => {
|
|
101
114
|
const file = configFile(`window.speedKit = { split: 0.1 };`);
|
|
102
|
-
const before = await file.evaluate(
|
|
115
|
+
const before = await file.evaluate(SHOP_DE, "https://www.shop.de");
|
|
103
116
|
file.setContent(`window.speedKit = { split: 0.5 };`);
|
|
104
|
-
const after = await file.evaluate(
|
|
117
|
+
const after = await file.evaluate(SHOP_DE, "https://www.shop.de");
|
|
105
118
|
expect(before.split).to.equal(0.1);
|
|
106
119
|
expect(after.split).to.equal(0.5);
|
|
107
120
|
});
|
|
@@ -109,8 +122,55 @@ describe("SpeedKitConfigFile", () => {
|
|
|
109
122
|
const source = `window.speedKit = { split: 0.5, appName: APP };`;
|
|
110
123
|
const remote = await VirtualSpeedKitConfigFile.createRemote(source, bundler);
|
|
111
124
|
const local = await evaluate(source);
|
|
112
|
-
const deployed = await remote.evaluate(
|
|
125
|
+
const deployed = await remote.evaluate(SHOP_DE, "https://www.shop.de");
|
|
113
126
|
expect(deployed).to.deep.equal(local);
|
|
114
127
|
expect(remote.getContent()).to.equal(source);
|
|
115
128
|
});
|
|
129
|
+
describe("with the enableSpeedKitConfigPlugins feature", () => {
|
|
130
|
+
const SOURCE = "window.speedKit = { split: 0.1 };";
|
|
131
|
+
const EMBEDDED = {
|
|
132
|
+
app: "shop-de",
|
|
133
|
+
features: { enableSpeedKitConfigPlugins: true },
|
|
134
|
+
configPluginsVersion: "@release",
|
|
135
|
+
};
|
|
136
|
+
function embeddedFile(bundled) {
|
|
137
|
+
const packjockel = new FakePackjockel(bundled);
|
|
138
|
+
const file = new SpeedKitConfigFile({
|
|
139
|
+
name: INTEGRATION_FILES.CONFIG.SPEED_KIT,
|
|
140
|
+
path: "config_SpeedKit.js",
|
|
141
|
+
content: SOURCE,
|
|
142
|
+
remoteKey: "config",
|
|
143
|
+
}, new BundleService("./", packjockel));
|
|
144
|
+
return { file, packjockel };
|
|
145
|
+
}
|
|
146
|
+
it("should bundle with packjockel and the tags of the customer", async () => {
|
|
147
|
+
const { file, packjockel } = embeddedFile(`SpeedKit.config = {};`);
|
|
148
|
+
await file.evaluate(EMBEDDED, "https://www.shop.de");
|
|
149
|
+
expect(packjockel.requests).to.have.length(1);
|
|
150
|
+
expect(packjockel.requests[0]).to.deep.equal({
|
|
151
|
+
entryPoints: { "config.js": SOURCE },
|
|
152
|
+
versions: EMBEDDED,
|
|
153
|
+
define: { APP: '"shop-de"' },
|
|
154
|
+
platform: "browser",
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
it("should read SpeedKit.config and the plugins pushed without a guard", async () => {
|
|
158
|
+
const { file } = embeddedFile(`SpeedKit.configPlugins.push({ name: "StripQueryParamPlugin" });
|
|
159
|
+
SpeedKit.config = { split: 0.3, appName: "shop-de" };`);
|
|
160
|
+
const config = await file.evaluate(EMBEDDED, "https://www.shop.de");
|
|
161
|
+
expect(config.split).to.equal(0.3);
|
|
162
|
+
expect(config.raw.appName).to.equal("shop-de");
|
|
163
|
+
});
|
|
164
|
+
it("should still read a config that assigns window.speedKit", async () => {
|
|
165
|
+
const { file } = embeddedFile(`window.speedKit = { split: 0.7 };`);
|
|
166
|
+
const config = await file.evaluate(EMBEDDED, "https://www.shop.de");
|
|
167
|
+
expect(config.split).to.equal(0.7);
|
|
168
|
+
});
|
|
169
|
+
it("should not reuse a reading of the other bundler", async () => {
|
|
170
|
+
const { file, packjockel } = embeddedFile(`SpeedKit.config = {};`);
|
|
171
|
+
await file.evaluate(EMBEDDED, "https://www.shop.de");
|
|
172
|
+
await file.evaluate({ app: "shop-de" }, "https://www.shop.de");
|
|
173
|
+
expect(packjockel.requests).to.have.length(1);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
116
176
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CustomerConfig, File, CustomerConfigInterface, FILE_TYPE } from "../integration-api-model.js";
|
|
2
|
+
import { VersionTag } from "./customer-config.js";
|
|
2
3
|
export declare class CustomerConfigFile extends File implements CustomerConfigInterface {
|
|
3
4
|
config: CustomerConfig;
|
|
4
5
|
readonly configName: string;
|
|
@@ -7,5 +8,19 @@ export declare class CustomerConfigFile extends File implements CustomerConfigIn
|
|
|
7
8
|
constructor(name: string, path: string, content: string, config: CustomerConfig, configName: string, testApp?: string);
|
|
8
9
|
setContent(content: string): void;
|
|
9
10
|
updateOrigins(origins: string[]): void;
|
|
11
|
+
/**
|
|
12
|
+
* Takes over the features the installation sets. The file then holds exactly these, and none
|
|
13
|
+
* when the installation sets none.
|
|
14
|
+
*
|
|
15
|
+
* @returns whether the features changed
|
|
16
|
+
*/
|
|
17
|
+
updateFeatures(live?: Record<string, unknown>): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Takes over the version tags of the installation. A tag the installation leaves at `latest` is
|
|
20
|
+
* removed from the file.
|
|
21
|
+
*
|
|
22
|
+
* @returns whether a tag changed
|
|
23
|
+
*/
|
|
24
|
+
updateVersions(live: Record<VersionTag, unknown>): boolean;
|
|
10
25
|
private updateConfigByContent;
|
|
11
26
|
}
|
|
@@ -2,6 +2,7 @@ import { CustomerConfig, File, FILE_TYPE, } from "../integration-api-model.js";
|
|
|
2
2
|
import { safe } from "../../../helpers/safe.js";
|
|
3
3
|
import CustomerConfigError from "../error/customer-config-error.js";
|
|
4
4
|
import { isSame } from "../array-helper.js";
|
|
5
|
+
import { declaredFields, versionsOfConfig, } from "./customer-config.js";
|
|
5
6
|
export class CustomerConfigFile extends File {
|
|
6
7
|
config;
|
|
7
8
|
configName;
|
|
@@ -28,6 +29,47 @@ export class CustomerConfigFile extends File {
|
|
|
28
29
|
configContent[this.configName].origins = origins;
|
|
29
30
|
this.setContent(JSON.stringify(configContent, null, 2));
|
|
30
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Takes over the features the installation sets. The file then holds exactly these, and none
|
|
34
|
+
* when the installation sets none.
|
|
35
|
+
*
|
|
36
|
+
* @returns whether the features changed
|
|
37
|
+
*/
|
|
38
|
+
updateFeatures(live) {
|
|
39
|
+
const features = declaredFields(live);
|
|
40
|
+
if (JSON.stringify(declaredFields(this.config.features)) ===
|
|
41
|
+
JSON.stringify(features)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const configContent = JSON.parse(this.getContent());
|
|
45
|
+
if (Object.keys(features).length > 0) {
|
|
46
|
+
configContent[this.configName].features = features;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
delete configContent[this.configName].features;
|
|
50
|
+
}
|
|
51
|
+
this.setContent(JSON.stringify(configContent, null, 2));
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Takes over the version tags of the installation. A tag the installation leaves at `latest` is
|
|
56
|
+
* removed from the file.
|
|
57
|
+
*
|
|
58
|
+
* @returns whether a tag changed
|
|
59
|
+
*/
|
|
60
|
+
updateVersions(live) {
|
|
61
|
+
if (JSON.stringify(versionsOfConfig(this.config)) === JSON.stringify(live)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const configContent = JSON.parse(this.getContent());
|
|
65
|
+
const others = Object.entries(configContent[this.configName]).filter(([key]) => !(key in live));
|
|
66
|
+
configContent[this.configName] = {
|
|
67
|
+
...Object.fromEntries(others),
|
|
68
|
+
...declaredFields(live),
|
|
69
|
+
};
|
|
70
|
+
this.setContent(JSON.stringify(configContent, null, 2));
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
31
73
|
updateConfigByContent() {
|
|
32
74
|
const configsResult = safe(() => {
|
|
33
75
|
return JSON.parse(this.getContent());
|