@speedkit/cli 4.36.1 → 4.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +12 -5
- package/dist/base/sk-command.d.ts +41 -0
- package/dist/base/sk-command.js +56 -0
- package/dist/commands/auto-prewarm.d.ts +6 -4
- package/dist/commands/auto-prewarm.js +13 -66
- package/dist/commands/autocomplete/fish.d.ts +2 -2
- package/dist/commands/autocomplete/fish.js +3 -2
- package/dist/commands/browser/clean.d.ts +2 -2
- package/dist/commands/browser/clean.js +6 -6
- package/dist/commands/browser/list.d.ts +2 -2
- package/dist/commands/browser/list.js +6 -7
- package/dist/commands/browser/update.d.ts +2 -2
- package/dist/commands/browser/update.js +9 -11
- package/dist/commands/bulk-deploy.d.ts +4 -2
- package/dist/commands/bulk-deploy.js +7 -37
- package/dist/commands/config/edit.d.ts +2 -2
- package/dist/commands/config/edit.js +2 -2
- package/dist/commands/config/setup.d.ts +5 -2
- package/dist/commands/config/setup.js +9 -19
- package/dist/commands/deploy.d.ts +12 -3
- package/dist/commands/deploy.js +14 -20
- package/dist/commands/diff-url-parameters.d.ts +3 -2
- package/dist/commands/diff-url-parameters.js +19 -16
- package/dist/commands/extension/add.d.ts +2 -2
- package/dist/commands/extension/add.js +6 -6
- package/dist/commands/extension/devtools.d.ts +2 -2
- package/dist/commands/extension/devtools.js +6 -7
- package/dist/commands/extension/list.d.ts +2 -2
- package/dist/commands/extension/list.js +5 -6
- package/dist/commands/extension/remove.d.ts +2 -2
- package/dist/commands/extension/remove.js +6 -6
- package/dist/commands/extension/update.d.ts +2 -2
- package/dist/commands/extension/update.js +5 -6
- package/dist/commands/find-pops.d.ts +2 -2
- package/dist/commands/find-pops.js +10 -11
- package/dist/commands/generate-customer-config.d.ts +5 -2
- package/dist/commands/generate-customer-config.js +9 -27
- package/dist/commands/generate-pop-config.d.ts +2 -2
- package/dist/commands/generate-pop-config.js +19 -15
- package/dist/commands/login.d.ts +2 -2
- package/dist/commands/login.js +6 -9
- package/dist/commands/onboarding.d.ts +19 -3
- package/dist/commands/onboarding.js +15 -11
- package/dist/commands/origin-request.d.ts +4 -2
- package/dist/commands/origin-request.js +10 -42
- package/dist/commands/prewarm.d.ts +4 -2
- package/dist/commands/prewarm.js +12 -56
- package/dist/commands/pull.d.ts +4 -2
- package/dist/commands/pull.js +9 -14
- package/dist/commands/query/parameter.d.ts +4 -2
- package/dist/commands/query/parameter.js +12 -19
- package/dist/commands/query/prewarm.d.ts +4 -2
- package/dist/commands/query/prewarm.js +16 -23
- package/dist/commands/revalidate.d.ts +4 -2
- package/dist/commands/revalidate.js +13 -56
- package/dist/commands/wpt-launcher.d.ts +2 -2
- package/dist/commands/wpt-launcher.js +16 -17
- package/dist/hooks/init/first-run.js +9 -10
- package/dist/models/context.d.ts +24 -0
- package/dist/models/context.js +31 -0
- package/dist/services/athena/athena-flags.d.ts +18 -0
- package/dist/services/athena/athena-flags.js +29 -0
- package/dist/services/athena/athena-service-build-context.d.ts +25 -0
- package/dist/services/athena/athena-service-build-context.js +4 -0
- package/dist/services/athena/athena-service-factory.d.ts +3 -16
- package/dist/services/athena/athena-service-factory.js +11 -27
- package/dist/services/athena/baqend-athena-service.d.ts +3 -14
- package/dist/services/athena/baqend-athena-service.js +8 -16
- package/dist/services/athena/index.d.ts +1 -0
- package/dist/services/athena/index.js +1 -0
- package/dist/services/athena/spec/baqend-athena-service.spec.js +2 -2
- package/dist/services/browser-fetch/browser-origin-fetch.d.ts +2 -2
- package/dist/services/browser-fetch/browser-origin-fetch.js +1 -1
- package/dist/services/browser-fetch/browser-origin-fetcher.d.ts +3 -3
- package/dist/services/browser-fetch/browser-origin-fetcher.js +5 -5
- package/dist/services/browser-fetch/spec/browser-origin-fetch.spec.js +10 -10
- package/dist/services/cli/cli-environment-factory.d.ts +25 -0
- package/dist/services/cli/cli-environment-factory.js +30 -0
- package/dist/services/cli/cli-environment.d.ts +73 -0
- package/dist/services/cli/cli-environment.js +216 -0
- package/dist/services/cli/cli-service-build-context.d.ts +10 -0
- package/dist/services/cli/cli-service-build-context.js +4 -0
- package/dist/services/cli/cli-service-factory.d.ts +7 -7
- package/dist/services/cli/cli-service-factory.js +7 -7
- package/dist/services/cli/cli-service-model.d.ts +0 -4
- package/dist/services/cli/cli-service-model.js +0 -6
- package/dist/services/cli/cli-service.d.ts +16 -2
- package/dist/services/cli/cli-service.js +17 -18
- package/dist/services/cli/cli-settings.d.ts +37 -0
- package/dist/services/cli/cli-settings.js +23 -0
- package/dist/services/cli/command-build-context.d.ts +23 -0
- package/dist/services/cli/index.d.ts +5 -1
- package/dist/services/cli/index.js +5 -1
- package/dist/services/cli/spec/cli-environment-detection.spec.js +52 -0
- package/dist/services/cli/spec/cli-environment.spec.js +125 -0
- package/dist/services/cli/spec/cli-service.spec.js +9 -19
- package/dist/services/config-api/client.d.ts +3 -3
- package/dist/services/config-api/client.js +4 -4
- package/dist/services/config-api/config-api-factory.js +3 -3
- package/dist/services/config-api/entity-manager-provider.d.ts +11 -0
- package/dist/services/config-api/{entity-manager-factory.js → entity-manager-provider.js} +7 -1
- package/dist/services/customer-config/customer-config-service-build-context.d.ts +33 -0
- package/dist/services/customer-config/customer-config-service-build-context.js +36 -0
- package/dist/services/customer-config/customer-config-service-factory.d.ts +3 -4
- package/dist/services/customer-config/customer-config-service-factory.js +5 -8
- package/dist/services/customer-config/customer-config-service.d.ts +2 -2
- package/dist/services/customer-config/index.d.ts +1 -1
- package/dist/services/customer-config/index.js +1 -1
- package/dist/services/customer-config/site-analyzer/index.d.ts +1 -0
- package/dist/services/customer-config/site-analyzer/index.js +1 -0
- package/dist/services/customer-config/site-analyzer/site-analyzer-service-build-context.d.ts +6 -0
- package/dist/services/customer-config/site-analyzer/site-analyzer-service-build-context.js +4 -0
- package/dist/services/customer-config/site-analyzer/site-analyzer-service-factory.d.ts +3 -3
- package/dist/services/customer-config/site-analyzer/site-analyzer-service-factory.js +4 -5
- package/dist/services/deploy/bulk/bulk-deploy-model.d.ts +0 -25
- package/dist/services/deploy/bulk/bulk-deploy-model.js +1 -27
- package/dist/services/deploy/bulk/bulk-deploy-service-build-context.d.ts +51 -0
- package/dist/services/deploy/bulk/bulk-deploy-service-build-context.js +50 -0
- package/dist/services/deploy/bulk/bulk-deploy-service-factory.d.ts +2 -4
- package/dist/services/deploy/bulk/bulk-deploy-service-factory.js +2 -5
- package/dist/services/deploy/bulk/bulk-deploy-service.d.ts +3 -2
- package/dist/services/deploy/bulk/config-deploy-factory.d.ts +3 -3
- package/dist/services/deploy/bulk/config-deploy-factory.js +16 -8
- package/dist/services/deploy/bulk/index.d.ts +1 -0
- package/dist/services/deploy/bulk/index.js +1 -0
- package/dist/services/deploy/checks/activation/customer-approval-check.d.ts +3 -1
- package/dist/services/deploy/checks/activation/customer-approval-check.js +4 -2
- package/dist/services/deploy/checks/pre-deploy/device-detection-changed-check.d.ts +3 -1
- package/dist/services/deploy/checks/pre-deploy/device-detection-changed-check.js +4 -2
- package/dist/services/deploy/checks/pre-deploy/split-change-check.d.ts +3 -1
- package/dist/services/deploy/checks/pre-deploy/split-change-check.js +4 -2
- package/dist/services/deploy/deploy-service-build-context.d.ts +63 -0
- package/dist/services/deploy/deploy-service-build-context.js +64 -0
- package/dist/services/deploy/deploy-service-factory.d.ts +5 -8
- package/dist/services/deploy/deploy-service-factory.js +28 -19
- package/dist/services/deploy/mr/base-config-reader.d.ts +6 -4
- package/dist/services/deploy/mr/base-config-reader.js +6 -8
- package/dist/services/deploy/mr/index.d.ts +1 -0
- package/dist/services/deploy/mr/index.js +1 -0
- package/dist/services/deploy/mr/merge-request-deploy-model.d.ts +0 -35
- package/dist/services/deploy/mr/merge-request-deploy-model.js +0 -34
- package/dist/services/deploy/mr/merge-request-deploy-service-build-context.d.ts +32 -0
- package/dist/services/deploy/mr/merge-request-deploy-service-build-context.js +20 -0
- package/dist/services/deploy/mr/merge-request-deploy-service-factory.d.ts +2 -4
- package/dist/services/deploy/mr/merge-request-deploy-service-factory.js +31 -10
- package/dist/services/deploy/mr/merge-request-deploy-service.d.ts +3 -2
- package/dist/services/deploy/spec/bulk/bulk-deploy-service.spec.js +14 -3
- package/dist/services/deploy/spec/checks/activation/customer-approval-check.spec.js +7 -5
- package/dist/services/deploy/spec/checks/pre-deploy/split-change-check.spec.js +2 -1
- package/dist/services/diff/diff-service-build-context.d.ts +14 -0
- package/dist/services/diff/diff-service-build-context.js +4 -0
- package/dist/services/diff/diff-service-factory.d.ts +4 -5
- package/dist/services/diff/diff-service-factory.js +4 -7
- package/dist/services/diff/index.d.ts +1 -1
- package/dist/services/diff/index.js +1 -1
- package/dist/services/document-handler-runtime/{context/document-handler-runtime-context.d.ts → document-handler-runtime-model.d.ts} +0 -5
- package/dist/services/document-handler-runtime/document-handler-runtime-service-build-context.d.ts +11 -0
- package/dist/services/document-handler-runtime/document-handler-runtime-service-build-context.js +4 -0
- package/dist/services/document-handler-runtime/document-handler-server.js +2 -2
- package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.d.ts +3 -6
- package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +14 -14
- package/dist/services/document-handler-runtime/server/request.js +1 -1
- package/dist/services/document-handler-runtime/templates/database-mock.d.ts +1 -1
- package/dist/services/document-handler-runtime/templates/database-mock.js +1 -1
- package/dist/services/integration-api/customer-config-flags.d.ts +16 -0
- package/dist/services/integration-api/customer-config-flags.js +30 -0
- package/dist/services/integration-api/handler/install-resource-handler.d.ts +8 -0
- package/dist/services/integration-api/handler/install-resource-handler.js +10 -1
- package/dist/services/integration-api/index.d.ts +1 -0
- package/dist/services/integration-api/index.js +1 -0
- package/dist/services/integration-api/integration-api-factory.d.ts +4 -6
- package/dist/services/integration-api/integration-api-factory.js +11 -11
- package/dist/services/integration-api/integration-api-model.d.ts +0 -9
- package/dist/services/integration-api/integration-api-model.js +0 -16
- package/dist/services/integration-api/integration-api-service-build-context.d.ts +19 -0
- package/dist/services/integration-api/integration-api-service-build-context.js +4 -0
- package/dist/services/integration-api/spec/config-plugin.spec.js +1 -1
- package/dist/services/integration-api/spec/integration-api-service.spec.js +7 -3
- package/dist/services/integration-api/spec/speed-kit-config-file.spec.js +9 -2
- package/dist/services/integration-api/struct/config-plugin.d.ts +1 -1
- package/dist/services/integration-api/struct/config-plugin.js +12 -7
- package/dist/services/integration-api/struct/speed-kit-config-file.d.ts +18 -2
- package/dist/services/integration-api/struct/speed-kit-config-file.js +22 -12
- package/dist/services/integration-api/struct/speed-kit-config.d.ts +1 -1
- package/dist/services/onboarding/browse/browse-service.d.ts +18 -0
- package/dist/services/onboarding/browse/browse-service.js +61 -0
- package/dist/services/onboarding/browse/browse-url.d.ts +10 -0
- package/dist/services/onboarding/browse/browse-url.js +19 -0
- package/dist/services/onboarding/browser/config/browser-config.d.ts +3 -3
- package/dist/services/onboarding/browser/config/browser-config.js +5 -5
- package/dist/services/onboarding/browser/executable/executable-validator.d.ts +3 -3
- package/dist/services/onboarding/browser/executable/executable-validator.js +20 -16
- package/dist/services/onboarding/browser/extension/extension-downloader.d.ts +3 -3
- package/dist/services/onboarding/browser/extension/extension-downloader.js +8 -6
- package/dist/services/onboarding/browser/extension/extension-validator.d.ts +3 -3
- package/dist/services/onboarding/browser/extension/extension-validator.js +4 -4
- package/dist/services/onboarding/browser/launch-browser.d.ts +9 -0
- package/dist/services/onboarding/browser/launch-browser.js +20 -0
- package/dist/services/onboarding/error/browse-domain-error.d.ts +6 -0
- package/dist/services/onboarding/error/browse-domain-error.js +11 -0
- package/dist/services/onboarding/error/missing-customer-path-error.d.ts +6 -0
- package/dist/services/onboarding/error/missing-customer-path-error.js +11 -0
- package/dist/services/onboarding/file-events/file-watcher.js +1 -0
- package/dist/services/onboarding/index.d.ts +1 -1
- package/dist/services/onboarding/index.js +1 -1
- package/dist/services/onboarding/onboarding-model.d.ts +8 -24
- package/dist/services/onboarding/onboarding-model.js +19 -87
- package/dist/services/onboarding/onboarding-service-build-context.d.ts +61 -0
- package/dist/services/onboarding/onboarding-service-build-context.js +79 -0
- package/dist/services/onboarding/onboarding-service-factory.d.ts +31 -6
- package/dist/services/onboarding/onboarding-service-factory.js +120 -48
- package/dist/services/onboarding/onboarding-service.d.ts +2 -0
- package/dist/services/onboarding/onboarding-service.js +5 -16
- package/dist/services/onboarding/spec/browse/browse-url.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/browse/browse-url.spec.js +28 -0
- package/dist/services/onboarding/spec/onboarding-model.spec.js +11 -6
- package/dist/services/onboarding/spec/onboarding-service-factory.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +155 -0
- package/dist/services/origin-request/index.d.ts +1 -1
- package/dist/services/origin-request/index.js +1 -1
- package/dist/services/origin-request/origin-request-service-build-context.d.ts +52 -0
- package/dist/services/origin-request/origin-request-service-build-context.js +54 -0
- package/dist/services/origin-request/origin-request-service-factory.d.ts +2 -5
- package/dist/services/origin-request/origin-request-service-factory.js +12 -12
- package/dist/services/origin-request/origin-request-service.d.ts +2 -2
- package/dist/services/pop-config/index.d.ts +1 -0
- package/dist/services/pop-config/index.js +1 -0
- package/dist/services/pop-config/pop-config-factory.d.ts +4 -1
- package/dist/services/pop-config/pop-config-factory.js +10 -3
- package/dist/services/pop-config/pop-config-service-build-context.d.ts +10 -0
- package/dist/services/pop-config/pop-config-service-build-context.js +4 -0
- package/dist/services/prewarm/auto-pre-warm-factory.d.ts +3 -31
- package/dist/services/prewarm/auto-pre-warm-factory.js +6 -11
- package/dist/services/prewarm/auto-pre-warm-service-build-context.d.ts +84 -0
- package/dist/services/prewarm/auto-pre-warm-service-build-context.js +68 -0
- package/dist/services/prewarm/index.d.ts +2 -0
- package/dist/services/prewarm/index.js +2 -0
- package/dist/services/prewarm/pre-warm-factory.d.ts +4 -5
- package/dist/services/prewarm/pre-warm-factory.js +6 -8
- package/dist/services/prewarm/pre-warm-model.d.ts +0 -10
- package/dist/services/prewarm/pre-warm-model.js +0 -18
- package/dist/services/prewarm/pre-warm-service-build-context.d.ts +47 -0
- package/dist/services/prewarm/pre-warm-service-build-context.js +64 -0
- package/dist/services/pull/index.d.ts +1 -0
- package/dist/services/pull/index.js +1 -0
- package/dist/services/pull/pull-service-build-context.d.ts +28 -0
- package/dist/services/pull/pull-service-build-context.js +17 -0
- package/dist/services/pull/pull-service-factory.d.ts +3 -5
- package/dist/services/pull/pull-service-factory.js +13 -14
- package/dist/services/pull/pull-service-model.d.ts +0 -5
- package/dist/services/pull/pull-service-model.js +0 -9
- package/dist/services/query-builder/query-builder-factory.d.ts +9 -7
- package/dist/services/query-builder/query-builder-factory.js +26 -15
- package/dist/{models/cli-parameters.d.ts → services/query-builder/query-builder-flags.d.ts} +1 -120
- package/dist/services/query-builder/query-builder-flags.js +150 -0
- package/dist/services/query-builder/query-builder-model.d.ts +1 -14
- package/dist/services/query-builder/query-builder-service-build-context.d.ts +113 -0
- package/dist/services/query-builder/query-builder-service-build-context.js +68 -0
- package/dist/services/query-builder/query-builder-service.d.ts +3 -3
- package/dist/services/query-builder/spec/query-builder-flags.spec.d.ts +1 -0
- package/dist/{models/spec/cli-parameters.spec.js → services/query-builder/spec/query-builder-flags.spec.js} +1 -1
- package/dist/services/revalidate/index.d.ts +1 -0
- package/dist/services/revalidate/index.js +1 -0
- package/dist/services/revalidate/revalidate-factory.d.ts +3 -5
- package/dist/services/revalidate/revalidate-factory.js +2 -6
- package/dist/services/revalidate/revalidate-model.d.ts +0 -9
- package/dist/services/revalidate/revalidate-model.js +0 -8
- package/dist/services/revalidate/revalidate-service-build-context.d.ts +38 -0
- package/dist/services/revalidate/revalidate-service-build-context.js +59 -0
- package/dist/services/setup/browser/browser-setup-service.d.ts +3 -4
- package/dist/services/setup/browser/browser-setup-service.js +16 -18
- package/dist/services/setup/difftool/difftool-setup-service.d.ts +3 -4
- package/dist/services/setup/difftool/difftool-setup-service.js +5 -7
- package/dist/services/setup/extension/extension-setup-service.d.ts +3 -4
- package/dist/services/setup/extension/extension-setup-service.js +8 -10
- package/dist/services/setup/index.d.ts +1 -1
- package/dist/services/setup/index.js +1 -1
- package/dist/services/setup/setup-service-build-context.d.ts +27 -0
- package/dist/services/setup/setup-service-build-context.js +26 -0
- package/dist/services/setup/setup-service-factory.d.ts +2 -6
- package/dist/services/setup/setup-service-factory.js +10 -18
- package/dist/services/setup/setup-service.d.ts +4 -5
- package/dist/services/setup/setup-service.js +6 -7
- package/oclif.manifest.json +155 -147
- package/package.json +4 -2
- package/dist/models/cli-parameters.js +0 -297
- package/dist/services/cli/cli-config.d.ts +0 -59
- package/dist/services/cli/cli-config.js +0 -180
- package/dist/services/cli/environment.d.ts +0 -15
- package/dist/services/cli/environment.js +0 -40
- package/dist/services/cli/spec/cli-config.spec.js +0 -117
- package/dist/services/cli/spec/environment.spec.js +0 -28
- package/dist/services/config-api/entity-manager-factory.d.ts +0 -5
- package/dist/services/customer-config/customer-config-service-context.d.ts +0 -13
- package/dist/services/customer-config/customer-config-service-context.js +0 -21
- package/dist/services/deploy/context/deploy-context.d.ts +0 -32
- package/dist/services/deploy/context/deploy-context.js +0 -72
- package/dist/services/diff/diff-model.d.ts +0 -9
- package/dist/services/diff/diff-model.js +0 -12
- package/dist/services/origin-request/origin-request-context.d.ts +0 -13
- package/dist/services/origin-request/origin-request-context.js +0 -23
- package/dist/services/query-builder/query-command.d.ts +0 -28
- package/dist/services/query-builder/query-command.js +0 -37
- package/dist/services/setup/setup-context.d.ts +0 -14
- package/dist/services/setup/setup-context.js +0 -15
- /package/dist/{models/spec/cli-parameters.spec.d.ts → services/cli/command-build-context.js} +0 -0
- /package/dist/services/cli/spec/{cli-config.spec.d.ts → cli-environment-detection.spec.d.ts} +0 -0
- /package/dist/services/cli/spec/{environment.spec.d.ts → cli-environment.spec.d.ts} +0 -0
- /package/dist/services/document-handler-runtime/{context/document-handler-runtime-context.js → document-handler-runtime-model.js} +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { CLI_CONFIG_IS_TEST, CLI_CONFIG_NAME, } from "../integration-api/customer-config-flags.js";
|
|
3
|
+
import { Context } from "../../models/context.js";
|
|
4
|
+
const args = {
|
|
5
|
+
// Optional for `--browse`, which analyses a site before its config exists; the factory requires it otherwise.
|
|
6
|
+
customerPath: Args.directory({
|
|
7
|
+
name: "customerPath",
|
|
8
|
+
required: false,
|
|
9
|
+
description: "The customer config path (optional with --browse)",
|
|
10
|
+
}),
|
|
11
|
+
};
|
|
12
|
+
const flags = {
|
|
13
|
+
...CLI_CONFIG_NAME,
|
|
14
|
+
...CLI_CONFIG_IS_TEST,
|
|
15
|
+
domain: Flags.string({
|
|
16
|
+
char: "d",
|
|
17
|
+
description: "Startup domain (optional)",
|
|
18
|
+
}),
|
|
19
|
+
local: Flags.boolean({
|
|
20
|
+
char: "l",
|
|
21
|
+
default: false,
|
|
22
|
+
description: "Run with local documentHandler",
|
|
23
|
+
}),
|
|
24
|
+
debuggingPort: Flags.boolean({
|
|
25
|
+
char: "p",
|
|
26
|
+
default: false,
|
|
27
|
+
description: "Enable remote debugging port (disables speculation rules/prerendering)",
|
|
28
|
+
}),
|
|
29
|
+
debugPort: Flags.integer({
|
|
30
|
+
default: 9222,
|
|
31
|
+
description: "Chrome remote debugging port (only used with -p/--headless). Use distinct ports to run multiple onboarding processes at once.",
|
|
32
|
+
}),
|
|
33
|
+
verboseLevel: Flags.boolean({
|
|
34
|
+
char: "v",
|
|
35
|
+
default: false,
|
|
36
|
+
description: "Show all messages",
|
|
37
|
+
}),
|
|
38
|
+
ignoreContentSecurityPolicy: Flags.boolean({
|
|
39
|
+
char: "s",
|
|
40
|
+
default: false,
|
|
41
|
+
description: `Removes header/meta "content-security-policy" for origin-responses`,
|
|
42
|
+
}),
|
|
43
|
+
headless: Flags.boolean({
|
|
44
|
+
default: false,
|
|
45
|
+
description: "Run Chrome in headless mode (for CI environments). Implicitly enables remote debugging port.",
|
|
46
|
+
}),
|
|
47
|
+
browse: Flags.boolean({
|
|
48
|
+
default: false,
|
|
49
|
+
description: "Open the live site in the onboarding Chrome, with its extensions, but without request interception or Speed Kit injection. Takes the domain from -d or from the customer config.",
|
|
50
|
+
}),
|
|
51
|
+
browserFetch: Flags.boolean({
|
|
52
|
+
default: false,
|
|
53
|
+
description: "Fetch every origin document with a second headless Chrome instead of a direct request. Only needed when bot protection refuses the CLI outright — a refusal is otherwise detected and rerouted on its own.",
|
|
54
|
+
}),
|
|
55
|
+
};
|
|
56
|
+
/** What `sk onboarding` starts: a local Speed Kit dev environment for one customer. */
|
|
57
|
+
export class OnboardingServiceBuildContext extends Context() {
|
|
58
|
+
static args = args;
|
|
59
|
+
static flags = flags;
|
|
60
|
+
static create(parsedArgs, parsedFlags, environment) {
|
|
61
|
+
return new OnboardingServiceBuildContext({
|
|
62
|
+
environment,
|
|
63
|
+
customerPath: parsedArgs.customerPath,
|
|
64
|
+
configName: parsedFlags.configName,
|
|
65
|
+
domain: parsedFlags["domain"],
|
|
66
|
+
local: parsedFlags.local,
|
|
67
|
+
ignoreContentSecurityPolicy: parsedFlags.ignoreContentSecurityPolicy,
|
|
68
|
+
cliPath: environment.oclif.root,
|
|
69
|
+
verboseLevel: parsedFlags.verboseLevel,
|
|
70
|
+
useTestConfig: parsedFlags.useTestConfig,
|
|
71
|
+
debuggingPort: parsedFlags.debuggingPort,
|
|
72
|
+
headless: parsedFlags.headless,
|
|
73
|
+
debugPort: parsedFlags.debugPort,
|
|
74
|
+
browserFetch: parsedFlags.browserFetch,
|
|
75
|
+
browse: parsedFlags.browse,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
OnboardingServiceBuildContext;
|
|
@@ -1,12 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { OnboardingServiceBuildContext } from "./onboarding-service-build-context.js";
|
|
2
|
+
import { BrowserContext } from "./onboarding-model.js";
|
|
3
3
|
import { OnboardingService } from "./onboarding-service.js";
|
|
4
|
+
import { BrowseService } from "./browse/browse-service.js";
|
|
5
|
+
import { BrowserExtensions } from "./browser/extension/extension-validator.js";
|
|
4
6
|
export declare class OnboardingServiceFactory {
|
|
5
7
|
private readonly context;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
constructor(context: OnboardingServiceBuildContext);
|
|
9
|
+
/**
|
|
10
|
+
* The service `sk onboarding` runs: the browse service under `--browse`, the onboarding service
|
|
11
|
+
* otherwise.
|
|
12
|
+
*
|
|
13
|
+
* @throws {MissingCustomerPathError} Without `--browse` and without a CUSTOMERPATH.
|
|
14
|
+
*/
|
|
15
|
+
getService(): Promise<OnboardingService | BrowseService>;
|
|
16
|
+
/** The live site in the onboarding Chrome: the same launch, none of the interception. */
|
|
17
|
+
private getBrowseService;
|
|
18
|
+
/** Only config_customer.json: browse mode reads its domain and chromeFlags, nothing else. */
|
|
19
|
+
private readCustomerConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the extensions and the Chrome executable, then builds the launch. Onboarding and
|
|
22
|
+
* browse mode both come through here, so they launch the same Chrome.
|
|
23
|
+
*/
|
|
24
|
+
protected prepareBrowser(domain: string, customerChromeFlags?: string[]): Promise<{
|
|
25
|
+
browserContext: BrowserContext;
|
|
26
|
+
browserExtensions: BrowserExtensions;
|
|
27
|
+
}>;
|
|
28
|
+
/** The launch for `domain`. It reads no mode of the build context, so browse mode cannot drift from onboarding. */
|
|
29
|
+
buildBrowserContext({ domain, browserVersionString, customerChromeFlags, }: {
|
|
30
|
+
domain: string;
|
|
31
|
+
browserVersionString: string;
|
|
32
|
+
customerChromeFlags?: string[];
|
|
33
|
+
}): BrowserContext;
|
|
34
|
+
private getOnboardingService;
|
|
10
35
|
private prepareMessagehandler;
|
|
11
36
|
private getAppToken;
|
|
12
37
|
private buildInstallResource;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { DEFAULT_DF_PATH, DEFAULT_DOCUMENT_HANDLER_PATH, DEFAULT_SNIPPET_PATH, DEFAULT_SW_PATH, } from "./onboarding-model.js";
|
|
1
2
|
import { safe } from "../../helpers/safe.js";
|
|
2
3
|
import { INTEGRATION_FILES } from "../../models/files.js";
|
|
3
|
-
import { AthenaServiceFactory } from "../athena/index.js";
|
|
4
|
+
import { AthenaServiceBuildContext, AthenaServiceFactory, } from "../athena/index.js";
|
|
4
5
|
import { BundleServiceFactory } from "../bundler/index.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { DiffServiceBuildContext, DiffServiceFactory } from "../diff/index.js";
|
|
7
|
+
import { DocumentHandlerRuntimeServiceBuildContext } from "../document-handler-runtime/document-handler-runtime-service-build-context.js";
|
|
7
8
|
import DocumentHandlerRuntimeServiceFactory from "../document-handler-runtime/factory/document-handler-runtime-service-factory.js";
|
|
8
|
-
import { ExternalFileReader,
|
|
9
|
+
import { ExternalFileReader, IntegrationApiServiceBuildContext, VirtualFile, ExternalRecipe, IntegrationApiFactory, } from "../integration-api/index.js";
|
|
9
10
|
import { InstallFileRecipe } from "./config-renderer/install-file-recipe.js";
|
|
10
11
|
import { SpeedKitInstallContext } from "./config-renderer/speed-kit-install-context.js";
|
|
11
12
|
import { Dashboard } from "./dashboard/index.js";
|
|
@@ -22,10 +23,13 @@ import { SpeedKitServiceWorkerJs } from "./fetch-events/speed-kit-service-worker
|
|
|
22
23
|
import { FileWatcher } from "./file-events/file-watcher.js";
|
|
23
24
|
import { BrowserContext, } from "./onboarding-model.js";
|
|
24
25
|
import { OnboardingService } from "./onboarding-service.js";
|
|
26
|
+
import { BrowseService } from "./browse/browse-service.js";
|
|
27
|
+
import { resolveBrowseUrl } from "./browse/browse-url.js";
|
|
28
|
+
import { MissingCustomerPathError } from "./error/missing-customer-path-error.js";
|
|
25
29
|
import { Cache } from "./request-cache/cache.js";
|
|
26
30
|
import { InstallSpeedKitHtmlTemplate } from "./templates/install-speed-kit-html-template.js";
|
|
27
31
|
import { InstallSpeedKitJsTemplate } from "./templates/install-speed-kit-js-template.js";
|
|
28
|
-
import { ExtensionValidator } from "./browser/extension/extension-validator.js";
|
|
32
|
+
import { ExtensionValidator, } from "./browser/extension/extension-validator.js";
|
|
29
33
|
import { DevtoolsExtensionApi } from "./browser/extension/devtools-extension-api.js";
|
|
30
34
|
import { ExtensionBridge } from "./browser/extension/extension-bridge.js";
|
|
31
35
|
import { TodoCollector } from "./todo-collector.js";
|
|
@@ -42,19 +46,89 @@ import { ExtensionDownloader } from "./browser/extension/extension-downloader.js
|
|
|
42
46
|
import { ExecutableValidator } from "./browser/executable/executable-validator.js";
|
|
43
47
|
import { applyOriginProxy, withOriginProxyFlag, } from "../../helpers/origin-proxy.js";
|
|
44
48
|
import { QueryBuilderFactory } from "../query-builder/query-builder-factory.js";
|
|
45
|
-
import {
|
|
49
|
+
import { ParameterQueryServiceBuildContext } from "../query-builder/query-builder-service-build-context.js";
|
|
46
50
|
import { formatChromeFeatureFinding, formatChromeFlagDuplicate, } from "../../helpers/chrome-flags.js";
|
|
47
51
|
export class OnboardingServiceFactory {
|
|
48
52
|
context;
|
|
49
|
-
|
|
50
|
-
cli;
|
|
51
|
-
constructor(context, cliConfig, cli) {
|
|
53
|
+
constructor(context) {
|
|
52
54
|
this.context = context;
|
|
53
|
-
this.cliConfig = cliConfig;
|
|
54
|
-
this.cli = cli;
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The service `sk onboarding` runs: the browse service under `--browse`, the onboarding service
|
|
58
|
+
* otherwise.
|
|
59
|
+
*
|
|
60
|
+
* @throws {MissingCustomerPathError} Without `--browse` and without a CUSTOMERPATH.
|
|
61
|
+
*/
|
|
56
62
|
async getService() {
|
|
57
|
-
|
|
63
|
+
if (this.context.browse) {
|
|
64
|
+
return this.getBrowseService();
|
|
65
|
+
}
|
|
66
|
+
if (!this.context.customerPath) {
|
|
67
|
+
throw new MissingCustomerPathError();
|
|
68
|
+
}
|
|
69
|
+
return this.getOnboardingService();
|
|
70
|
+
}
|
|
71
|
+
/** The live site in the onboarding Chrome: the same launch, none of the interception. */
|
|
72
|
+
async getBrowseService() {
|
|
73
|
+
const cli = this.context.environment.cli;
|
|
74
|
+
const customerConfig = this.context.customerPath
|
|
75
|
+
? await this.readCustomerConfig()
|
|
76
|
+
: undefined;
|
|
77
|
+
applyOriginProxy(customerConfig?.chromeFlags, cli);
|
|
78
|
+
const url = resolveBrowseUrl(this.context.domain, customerConfig);
|
|
79
|
+
const { browserContext } = await this.prepareBrowser(url, customerConfig?.chromeFlags);
|
|
80
|
+
return new BrowseService(browserContext, cli);
|
|
81
|
+
}
|
|
82
|
+
/** Only config_customer.json: browse mode reads its domain and chromeFlags, nothing else. */
|
|
83
|
+
async readCustomerConfig() {
|
|
84
|
+
const integrationApi = new IntegrationApiFactory(new IntegrationApiServiceBuildContext({
|
|
85
|
+
environment: this.context.environment,
|
|
86
|
+
basePath: this.context.customerPath,
|
|
87
|
+
configName: this.context.configName,
|
|
88
|
+
whitelist: [INTEGRATION_FILES.CONFIG.CUSTOMER],
|
|
89
|
+
blockedFolders: [],
|
|
90
|
+
useTestConfig: this.context.useTestConfig,
|
|
91
|
+
})).buildService();
|
|
92
|
+
const files = await integrationApi.run();
|
|
93
|
+
return files.getCustomerConfig().config;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Resolves the extensions and the Chrome executable, then builds the launch. Onboarding and
|
|
97
|
+
* browse mode both come through here, so they launch the same Chrome.
|
|
98
|
+
*/
|
|
99
|
+
async prepareBrowser(domain, customerChromeFlags) {
|
|
100
|
+
const cli = this.context.environment.cli;
|
|
101
|
+
const extensionDownloader = new ExtensionDownloader(this.context.environment, cli);
|
|
102
|
+
const browserExtensions = await new ExtensionValidator(extensionDownloader, this.context.environment, cli).getValidBrowserExtensions();
|
|
103
|
+
this.context.environment.settings.chromeExtensionPaths =
|
|
104
|
+
browserExtensions.paths.join(",");
|
|
105
|
+
const browserValidator = new ExecutableValidator(this.context.environment, cli);
|
|
106
|
+
const browserVersionString = await browserValidator.validateOrInstall();
|
|
107
|
+
const browserContext = this.buildBrowserContext({
|
|
108
|
+
domain,
|
|
109
|
+
browserVersionString,
|
|
110
|
+
customerChromeFlags,
|
|
111
|
+
});
|
|
112
|
+
for (const duplicate of browserContext.findDuplicateFlags()) {
|
|
113
|
+
cli.writeWarning(formatChromeFlagDuplicate(duplicate));
|
|
114
|
+
}
|
|
115
|
+
for (const finding of browserContext.findFeatureFindings()) {
|
|
116
|
+
cli.writeWarning(formatChromeFeatureFinding(finding));
|
|
117
|
+
}
|
|
118
|
+
if (this.context.debuggingPort || this.context.headless) {
|
|
119
|
+
cli.writeWarning(`Chrome remote debugging enabled on port ${this.context.debugPort}.`);
|
|
120
|
+
}
|
|
121
|
+
if (this.context.headless) {
|
|
122
|
+
cli.writeWarning("Running in headless mode.");
|
|
123
|
+
}
|
|
124
|
+
return { browserContext, browserExtensions };
|
|
125
|
+
}
|
|
126
|
+
/** The launch for `domain`. It reads no mode of the build context, so browse mode cannot drift from onboarding. */
|
|
127
|
+
buildBrowserContext({ domain, browserVersionString, customerChromeFlags, }) {
|
|
128
|
+
return new BrowserContext(domain, browserVersionString, withOriginProxyFlag(customerChromeFlags), this.context.environment, undefined, this.context.debuggingPort, this.context.headless, this.context.debugPort);
|
|
129
|
+
}
|
|
130
|
+
async getOnboardingService() {
|
|
131
|
+
const cli = this.context.environment.cli;
|
|
58
132
|
const files = await this.getIntegrationFiles(cli);
|
|
59
133
|
const customerConfig = files.getCustomerConfig().config;
|
|
60
134
|
// Before any origin request, so Chrome and the CLI agree on the route out.
|
|
@@ -62,7 +136,7 @@ export class OnboardingServiceFactory {
|
|
|
62
136
|
// Also before any origin request: an origin behind bot protection refuses the CLI outright,
|
|
63
137
|
// and `auto` only reaches for the browser once one actually has.
|
|
64
138
|
const browserFetch = installBrowserOriginFetch({
|
|
65
|
-
|
|
139
|
+
environment: this.context.environment,
|
|
66
140
|
logger: cli,
|
|
67
141
|
mode: this.context.browserFetch ? "always" : "auto",
|
|
68
142
|
});
|
|
@@ -71,36 +145,19 @@ export class OnboardingServiceFactory {
|
|
|
71
145
|
}
|
|
72
146
|
const domainToStart = await this.getUrlForTest(customerConfig, cli);
|
|
73
147
|
const cache = new Cache(cli);
|
|
74
|
-
const
|
|
148
|
+
const documentHandler = await new DocumentHandlerRuntimeServiceFactory(new DocumentHandlerRuntimeServiceBuildContext({
|
|
149
|
+
environment: this.context.environment,
|
|
75
150
|
configName: this.context.configName,
|
|
76
151
|
customerPath: this.context.customerPath,
|
|
77
152
|
verboseLevel: this.context.verboseLevel,
|
|
78
|
-
};
|
|
79
|
-
const documentHandler = await new DocumentHandlerRuntimeServiceFactory(documentHandlerContext, this.cliConfig, files, cli).buildDocumentHandlerServer();
|
|
153
|
+
}), files).buildDocumentHandlerServer();
|
|
80
154
|
const bundler = new BundleServiceFactory(this.context.customerPath).buildService();
|
|
81
155
|
const skTemplate = new InstallSpeedKitJsTemplate();
|
|
82
156
|
const speedKitInstallContext = new SpeedKitInstallContext(customerConfig, this.context.configName, files, bundler, skTemplate, this.context.local);
|
|
83
157
|
await this.buildInstallResource(speedKitInstallContext, files, cli);
|
|
84
|
-
const
|
|
85
|
-
const browserExtensions = await new ExtensionValidator(extensionDownloader, this.cliConfig, cli).getValidBrowserExtensions();
|
|
86
|
-
this.cliConfig.chromeExtensionPaths = browserExtensions.paths.join(",");
|
|
87
|
-
const browserValidator = new ExecutableValidator(this.cliConfig, cli);
|
|
88
|
-
const browserVersionString = await browserValidator.validateOrInstall();
|
|
89
|
-
const browserContext = new BrowserContext(domainToStart, browserVersionString, withOriginProxyFlag(customerConfig.chromeFlags), this.cliConfig, undefined, this.context.debuggingPort, this.context.headless, this.context.debugPort);
|
|
90
|
-
for (const duplicate of browserContext.findDuplicateFlags()) {
|
|
91
|
-
cli.writeWarning(formatChromeFlagDuplicate(duplicate));
|
|
92
|
-
}
|
|
93
|
-
for (const finding of browserContext.findFeatureFindings()) {
|
|
94
|
-
cli.writeWarning(formatChromeFeatureFinding(finding));
|
|
95
|
-
}
|
|
96
|
-
if (this.context.debuggingPort || this.context.headless) {
|
|
97
|
-
cli.writeWarning(`Chrome remote debugging enabled on port ${this.context.debugPort}.`);
|
|
98
|
-
}
|
|
99
|
-
if (this.context.headless) {
|
|
100
|
-
cli.writeWarning("Running in headless mode.");
|
|
101
|
-
}
|
|
158
|
+
const { browserContext, browserExtensions } = await this.prepareBrowser(domainToStart, customerConfig.chromeFlags);
|
|
102
159
|
const fileWatcher = new FileWatcher(cli, customerConfig, files, documentHandler, browserContext, cache);
|
|
103
|
-
const athenaClient = (await this.getAthenaClient(customerConfig.app
|
|
160
|
+
const athenaClient = (await this.getAthenaClient(customerConfig.app)) || null;
|
|
104
161
|
const messageHandler = await this.prepareMessagehandler(athenaClient, files, customerConfig);
|
|
105
162
|
const speedKitServiceWorkerJs = new SpeedKitServiceWorkerJs(customerConfig, files.getByName(INTEGRATION_FILES.CUSTOM.SW));
|
|
106
163
|
const fetchHandler = await this.getFetchEventHandler(files, customerConfig, documentHandler, cache, cli, browserContext, athenaClient, messageHandler, fileWatcher, speedKitServiceWorkerJs);
|
|
@@ -112,7 +169,7 @@ export class OnboardingServiceFactory {
|
|
|
112
169
|
messageHandler.addMessage({
|
|
113
170
|
id: "skCli",
|
|
114
171
|
data: {
|
|
115
|
-
version: this.
|
|
172
|
+
version: this.context.environment.oclif.version,
|
|
116
173
|
app: customerConfig.app,
|
|
117
174
|
customerConfigPath: path.resolve(this.context.customerPath, this.context.configName),
|
|
118
175
|
},
|
|
@@ -154,8 +211,11 @@ export class OnboardingServiceFactory {
|
|
|
154
211
|
}
|
|
155
212
|
cli.failAction("ONBOARDING:BUILD:INSTALL_RESOURCE", result.error);
|
|
156
213
|
}
|
|
157
|
-
async getAthenaClient(app
|
|
158
|
-
const athenaFactory = new AthenaServiceFactory(
|
|
214
|
+
async getAthenaClient(app) {
|
|
215
|
+
const athenaFactory = new AthenaServiceFactory(new AthenaServiceBuildContext({
|
|
216
|
+
environment: this.context.environment,
|
|
217
|
+
app,
|
|
218
|
+
}));
|
|
159
219
|
const result = await safe(athenaFactory.getService());
|
|
160
220
|
if (result.success === true) {
|
|
161
221
|
return result.data;
|
|
@@ -169,12 +229,17 @@ export class OnboardingServiceFactory {
|
|
|
169
229
|
const configApi = this.getConfigApi(customerConfig.app);
|
|
170
230
|
const serverConfig = await this.getSpeedKitServerConfig(configApi, cli);
|
|
171
231
|
const crawler = new Crawler(cli, serverConfig);
|
|
172
|
-
const parameterQueryBuilder = await new QueryBuilderFactory({
|
|
232
|
+
const parameterQueryBuilder = await new QueryBuilderFactory(new ParameterQueryServiceBuildContext({
|
|
233
|
+
environment: this.context.environment,
|
|
173
234
|
configName: this.context.configName,
|
|
174
235
|
customerPath: this.context.customerPath,
|
|
175
|
-
isWindows: this.
|
|
176
|
-
}
|
|
177
|
-
const DiffService = new DiffServiceFactory(new
|
|
236
|
+
isWindows: this.context.environment.oclif.windows,
|
|
237
|
+
})).buildService();
|
|
238
|
+
const DiffService = new DiffServiceFactory(new DiffServiceBuildContext({
|
|
239
|
+
environment: this.context.environment,
|
|
240
|
+
executablePath: this.context.environment.settings.diffExec,
|
|
241
|
+
executableTemplate: this.context.environment.settings.diffExecTemplate,
|
|
242
|
+
})).getService();
|
|
178
243
|
const requestDiffService = new RequestDiffService(DiffService, documentHandler, cli);
|
|
179
244
|
const handlers = [
|
|
180
245
|
new CustomerDomainDocumentResponse(customerConfig, files.getByName(INTEGRATION_FILES.CONFIG.DYNAMIC_BLOCKS), files.getByName(INTEGRATION_FILES.CONFIG.DYNAMIC_STYLES), this.context.ignoreContentSecurityPolicy),
|
|
@@ -210,13 +275,20 @@ export class OnboardingServiceFactory {
|
|
|
210
275
|
const swPath = path.join(speedKitBuildPath, "sw.js");
|
|
211
276
|
const dfPath = path.join(speedKitBuildPath, "dynamic-fetcher.js");
|
|
212
277
|
const loaderPath = path.join(speedKitBuildPath, "snippet.js");
|
|
213
|
-
const integrationApiContext = new
|
|
214
|
-
|
|
278
|
+
const integrationApiContext = new IntegrationApiServiceBuildContext({
|
|
279
|
+
environment: this.context.environment,
|
|
280
|
+
basePath: this.context.customerPath,
|
|
281
|
+
configName: this.context.configName,
|
|
282
|
+
whitelist: [],
|
|
283
|
+
blockedFolders: [],
|
|
284
|
+
useTestConfig: this.context.useTestConfig,
|
|
285
|
+
});
|
|
286
|
+
const integrationApi = new IntegrationApiFactory(integrationApiContext).buildService();
|
|
215
287
|
const externalFileReader = new ExternalFileReader();
|
|
216
288
|
const integrationApiArray = [
|
|
217
289
|
{
|
|
218
290
|
name: INTEGRATION_FILES.CUSTOM.DOCUMENT_HANDLER,
|
|
219
|
-
recipe: new ExternalRecipe(
|
|
291
|
+
recipe: new ExternalRecipe(DEFAULT_DOCUMENT_HANDLER_PATH, externalFileReader),
|
|
220
292
|
},
|
|
221
293
|
];
|
|
222
294
|
// if speed-kit is npm-linked, use linked local files else fetch latest released sw and df
|
|
@@ -239,13 +311,13 @@ export class OnboardingServiceFactory {
|
|
|
239
311
|
else {
|
|
240
312
|
integrationApiArray.push({
|
|
241
313
|
name: INTEGRATION_FILES.CUSTOM.SW,
|
|
242
|
-
recipe: new ExternalRecipe(
|
|
314
|
+
recipe: new ExternalRecipe(DEFAULT_SW_PATH, externalFileReader),
|
|
243
315
|
}, {
|
|
244
316
|
name: INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER,
|
|
245
|
-
recipe: new ExternalRecipe(
|
|
317
|
+
recipe: new ExternalRecipe(DEFAULT_DF_PATH, externalFileReader),
|
|
246
318
|
}, {
|
|
247
319
|
name: INTEGRATION_FILES.CUSTOM.LOADER,
|
|
248
|
-
recipe: new ExternalRecipe(
|
|
320
|
+
recipe: new ExternalRecipe(DEFAULT_SNIPPET_PATH, externalFileReader),
|
|
249
321
|
});
|
|
250
322
|
}
|
|
251
323
|
return integrationApi.run(integrationApiArray);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import puppeteerExtra from "puppeteer-extra";
|
|
2
1
|
import { BROWSER_EVENTS, CDP_SESSION, } from "./onboarding-model.js";
|
|
3
2
|
import { safe } from "../../helpers/safe.js";
|
|
4
3
|
import { isEmptyServiceWorkerUrl } from "./empty-service-worker.js";
|
|
4
|
+
import { launchBrowser, resetBrowserState } from "./browser/launch-browser.js";
|
|
5
5
|
// A SW version activating later than this after the last locally served sw.js
|
|
6
6
|
// cannot originate from our interception — it is a deployed-build takeover.
|
|
7
7
|
const LOCAL_SW_SERVE_GRACE_MS = 10_000;
|
|
@@ -60,7 +60,7 @@ export class OnboardingService {
|
|
|
60
60
|
await safe(this.browserFetch.close());
|
|
61
61
|
}
|
|
62
62
|
async prepareBrowser(localController) {
|
|
63
|
-
const browser = await
|
|
63
|
+
const browser = await launchBrowser(this.browserContext);
|
|
64
64
|
for (const target of browser.targets()) {
|
|
65
65
|
if (target.type() === "browser") {
|
|
66
66
|
await this.fetchEventHandler.handleRequestFetchEvents(target);
|
|
@@ -109,19 +109,7 @@ export class OnboardingService {
|
|
|
109
109
|
}
|
|
110
110
|
async prepareCleanState(page) {
|
|
111
111
|
const cdpSession = await page.target().createCDPSession();
|
|
112
|
-
|
|
113
|
-
await cdpSession.send("ServiceWorker.enable");
|
|
114
|
-
await cdpSession.send("ServiceWorker.unregister", {
|
|
115
|
-
scopeURL: this.browserContext.domain,
|
|
116
|
-
});
|
|
117
|
-
// clear storage for a clean start
|
|
118
|
-
await cdpSession.send("Storage.clearCookies");
|
|
119
|
-
await cdpSession.send("Storage.clearDataForOrigin", {
|
|
120
|
-
origin: this.browserContext.domain,
|
|
121
|
-
storageTypes: "all",
|
|
122
|
-
});
|
|
123
|
-
await cdpSession.send("Emulation.clearDeviceMetricsOverride");
|
|
124
|
-
await cdpSession.send("Emulation.clearGeolocationOverride");
|
|
112
|
+
await resetBrowserState(cdpSession, this.browserContext.domain);
|
|
125
113
|
this.registerForeignSwGuard(page, cdpSession);
|
|
126
114
|
safe(() => {
|
|
127
115
|
cdpSession.on(CDP_SESSION.EVENTS.SERVICE_WORKER.REGISTRATION_UPDATED, ({ registrations, }) => {
|
|
@@ -226,7 +214,8 @@ export class OnboardingService {
|
|
|
226
214
|
await safe(page.goto(goto.toString()));
|
|
227
215
|
}
|
|
228
216
|
}
|
|
229
|
-
|
|
217
|
+
/** Resolves once `signal` aborts. */
|
|
218
|
+
export function waitForAbort(signal) {
|
|
230
219
|
if (signal.aborted) {
|
|
231
220
|
return Promise.resolve();
|
|
232
221
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
|
+
import { resolveBrowseUrl } from "../../browse/browse-url.js";
|
|
4
|
+
import { BrowseDomainError } from "../../error/browse-domain-error.js";
|
|
5
|
+
describe("resolveBrowseUrl", () => {
|
|
6
|
+
const customerConfig = {
|
|
7
|
+
domain: "www.example.com",
|
|
8
|
+
origins: ["https://www.example.com", "https://shop.example.com"],
|
|
9
|
+
};
|
|
10
|
+
it("takes the --domain flag over the customer config", () => {
|
|
11
|
+
expect(resolveBrowseUrl("other.example.com", customerConfig)).to.equal("https://other.example.com/");
|
|
12
|
+
});
|
|
13
|
+
it("takes the domain of the customer config without a flag", () => {
|
|
14
|
+
expect(resolveBrowseUrl(undefined, customerConfig)).to.equal("https://www.example.com/");
|
|
15
|
+
});
|
|
16
|
+
it("falls back to the first origin when the config names no domain", () => {
|
|
17
|
+
expect(resolveBrowseUrl(undefined, {
|
|
18
|
+
domain: undefined,
|
|
19
|
+
origins: ["https://shop.example.com"],
|
|
20
|
+
})).to.equal("https://shop.example.com/");
|
|
21
|
+
});
|
|
22
|
+
it("keeps an explicit scheme and path", () => {
|
|
23
|
+
expect(resolveBrowseUrl("http://example.com/de/")).to.equal("http://example.com/de/");
|
|
24
|
+
});
|
|
25
|
+
it("fails without a flag and without a customer config", () => {
|
|
26
|
+
expect(() => resolveBrowseUrl()).to.throw(BrowseDomainError);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -4,19 +4,21 @@ import { BrowserContext, HEADLESS_DEFAULT_ARGS_TO_DROP, } from "../onboarding-mo
|
|
|
4
4
|
import { buildHeadedUserAgent } from "../browser/executable/headed-user-agent.js";
|
|
5
5
|
// Providing chromeUserProfilePath keeps BrowserContext off the filesystem
|
|
6
6
|
// (it skips the temp-profile branch in the constructor).
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const environment = {
|
|
8
|
+
settings: {
|
|
9
|
+
chromePath: "/usr/bin/google-chrome",
|
|
10
|
+
chromeUserProfilePath: "/tmp/sk-test-profile",
|
|
11
|
+
},
|
|
10
12
|
};
|
|
11
13
|
function newContext(headless, { chromeFlags = [], userAgent, browserVersionString = "Google Chrome for Testing 146.0.7680.165", } = {}) {
|
|
12
|
-
return new BrowserContext("example.com", browserVersionString, chromeFlags,
|
|
14
|
+
return new BrowserContext("example.com", browserVersionString, chromeFlags, environment, userAgent, false, headless, undefined);
|
|
13
15
|
}
|
|
14
16
|
function launchArgs(headless, overrides = {}) {
|
|
15
17
|
return newContext(headless, overrides).getPuppeteerLaunchOptions()
|
|
16
18
|
.args;
|
|
17
19
|
}
|
|
18
20
|
function remoteDebuggingArg(debuggingPort, headless, debugPort) {
|
|
19
|
-
const context = new BrowserContext("example.com", "Chrome/120", [],
|
|
21
|
+
const context = new BrowserContext("example.com", "Chrome/120", [], environment, undefined, debuggingPort, headless, debugPort);
|
|
20
22
|
const args = context.getPuppeteerLaunchOptions().args;
|
|
21
23
|
return args.find((arg) => arg.startsWith("--remote-debugging-port="));
|
|
22
24
|
}
|
|
@@ -98,7 +100,10 @@ describe("BrowserContext headless/headed parity", () => {
|
|
|
98
100
|
});
|
|
99
101
|
describe("BrowserContext system chromeFlags", () => {
|
|
100
102
|
function systemContext(chromeFlags, systemFlags, debuggingPort = false) {
|
|
101
|
-
return new BrowserContext("example.com", "Chrome/120", chromeFlags, {
|
|
103
|
+
return new BrowserContext("example.com", "Chrome/120", chromeFlags, {
|
|
104
|
+
...environment,
|
|
105
|
+
settings: { ...environment.settings, chromeFlags: systemFlags },
|
|
106
|
+
}, undefined, debuggingPort, false, undefined);
|
|
102
107
|
}
|
|
103
108
|
it("appends the system flags after every other arg", () => {
|
|
104
109
|
const args = systemContext(["--customer"], ["--system-a", "--system-b"], true).getPuppeteerLaunchOptions().args;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|