@speedkit/cli 4.36.1 → 4.36.2
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 +7 -0
- 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 +18 -3
- package/dist/commands/onboarding.js +13 -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/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 +17 -15
- package/dist/services/onboarding/browser/extension/extension-downloader.d.ts +3 -3
- package/dist/services/onboarding/browser/extension/extension-downloader.js +6 -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/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 +57 -0
- package/dist/services/onboarding/onboarding-service-build-context.js +67 -0
- package/dist/services/onboarding/onboarding-service-factory.d.ts +2 -5
- package/dist/services/onboarding/onboarding-service-factory.js +47 -34
- package/dist/services/onboarding/spec/onboarding-model.spec.js +11 -6
- 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 +1 -1
- 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
|
@@ -9,17 +9,17 @@ import { isDevtoolsExtensionName } from "./extension-bridge.js";
|
|
|
9
9
|
const MAX_BUILD_FOLDER_DEPTH = 3;
|
|
10
10
|
export class ExtensionValidator {
|
|
11
11
|
extensionDownloader;
|
|
12
|
-
|
|
12
|
+
environment;
|
|
13
13
|
cli;
|
|
14
|
-
constructor(extensionDownloader,
|
|
14
|
+
constructor(extensionDownloader, environment, cli) {
|
|
15
15
|
this.extensionDownloader = extensionDownloader;
|
|
16
|
-
this.
|
|
16
|
+
this.environment = environment;
|
|
17
17
|
this.cli = cli;
|
|
18
18
|
}
|
|
19
19
|
async getValidBrowserExtensions() {
|
|
20
20
|
const validExtensions = [];
|
|
21
21
|
this.cli.startAction("ONBOARDING:RESOLVE:BROWSER_EXTENSION", "resolve browserExtensions");
|
|
22
|
-
const browserExtensions = this.
|
|
22
|
+
const browserExtensions = this.environment.settings.chromeExtensionPaths
|
|
23
23
|
.split(",")
|
|
24
24
|
.filter((entry) => {
|
|
25
25
|
return entry.trim().length > 0;
|
|
@@ -3,9 +3,8 @@ import { Protocol } from "puppeteer-core";
|
|
|
3
3
|
import { AbortResponse } from "./browser/abort-response.js";
|
|
4
4
|
import { task } from "./todo-collector.js";
|
|
5
5
|
import { VanillaPuppeteer } from "puppeteer-extra";
|
|
6
|
-
import { Command } from "@oclif/core/command";
|
|
7
6
|
import { ChromeFeatureFinding, ChromeFlagDuplicate } from "../../helpers/chrome-flags.js";
|
|
8
|
-
import {
|
|
7
|
+
import { CliEnvironment } from "../cli/index.js";
|
|
9
8
|
export declare const HEADLESS_PARITY_ARGS: string[];
|
|
10
9
|
declare const HEADLESS_DEFAULT_ARGS_TO_DROP: string[];
|
|
11
10
|
export { HEADLESS_DEFAULT_ARGS_TO_DROP };
|
|
@@ -40,7 +39,7 @@ export declare class BrowserContext {
|
|
|
40
39
|
readonly domain: string;
|
|
41
40
|
readonly browserVersionString: string;
|
|
42
41
|
readonly chromeFlags?: string[];
|
|
43
|
-
readonly
|
|
42
|
+
readonly environment?: CliEnvironment;
|
|
44
43
|
userAgent?: string;
|
|
45
44
|
readonly debuggingPort: boolean;
|
|
46
45
|
readonly headless: boolean;
|
|
@@ -49,7 +48,7 @@ export declare class BrowserContext {
|
|
|
49
48
|
private readonly skArgs;
|
|
50
49
|
readonly browserArgs: string[];
|
|
51
50
|
readonly chromePath: string;
|
|
52
|
-
constructor(domain: string, browserVersionString?: string, chromeFlags?: string[],
|
|
51
|
+
constructor(domain: string, browserVersionString?: string, chromeFlags?: string[], environment?: CliEnvironment, userAgent?: string, debuggingPort?: boolean, headless?: boolean, debugPort?: number);
|
|
53
52
|
/**
|
|
54
53
|
* Applied as a launch flag rather than over CDP on purpose: a per-page
|
|
55
54
|
* `Network.setUserAgentOverride` never reaches the Service Worker, so Speed Kit's dynamic-block
|
|
@@ -76,26 +75,11 @@ export interface FetchRequestPausedEventHandler {
|
|
|
76
75
|
handle(event: Protocol.Fetch.RequestPausedEvent, client: CDPSession): Promise<AbortResponse | Partial<Protocol.Fetch.FulfillRequestRequest> | null>;
|
|
77
76
|
readonly patterns: Protocol.Fetch.RequestPattern[];
|
|
78
77
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
readonly ignoreContentSecurityPolicy: boolean;
|
|
85
|
-
readonly cliPath: string;
|
|
86
|
-
readonly verboseLevel?: boolean;
|
|
87
|
-
readonly useTestConfig: boolean;
|
|
88
|
-
readonly debuggingPort: boolean;
|
|
89
|
-
readonly headless: boolean;
|
|
90
|
-
readonly debugPort: number;
|
|
91
|
-
readonly browserFetch: boolean;
|
|
92
|
-
static flags: Record<string, Command.Flag>;
|
|
93
|
-
readonly DEFAULT_DF_PATH = "https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js";
|
|
94
|
-
readonly DEFAULT_DOCUMENT_HANDLER_PATH = "https://www.baqend.com/speed-kit-handler/latest/DocumentHandler.js";
|
|
95
|
-
readonly DEFAULT_SNIPPET_PATH = "https://www.baqend.com/speed-kit/latest/snippet.js";
|
|
96
|
-
readonly DEFAULT_SW_PATH = "https://www.baqend.com/speed-kit/latest/sw.js";
|
|
97
|
-
constructor(customerPath: string, configName: string, domain: string, local: boolean, ignoreContentSecurityPolicy: boolean, cliPath: string, verboseLevel?: boolean, useTestConfig?: boolean, debuggingPort?: boolean, headless?: boolean, debugPort?: number, browserFetch?: boolean);
|
|
98
|
-
}
|
|
78
|
+
/** Where the Speed Kit parts come from when a customer brings none of its own. */
|
|
79
|
+
export declare const DEFAULT_DF_PATH = "https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js";
|
|
80
|
+
export declare const DEFAULT_DOCUMENT_HANDLER_PATH = "https://www.baqend.com/speed-kit-handler/latest/DocumentHandler.js";
|
|
81
|
+
export declare const DEFAULT_SNIPPET_PATH = "https://www.baqend.com/speed-kit/latest/snippet.js";
|
|
82
|
+
export declare const DEFAULT_SW_PATH = "https://www.baqend.com/speed-kit/latest/sw.js";
|
|
99
83
|
export interface SpeedKitServerConfigAuthentication {
|
|
100
84
|
password: string;
|
|
101
85
|
type: "basic";
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Flags } from "@oclif/core";
|
|
2
|
-
import { CLI_CONFIG_IS_TEST, CLI_CONFIG_NAME, CLIParameters, CLIParametersChar, } from "../../models/cli-parameters.js";
|
|
3
1
|
import { BrowserConfig } from "./browser/config/browser-config.js";
|
|
4
2
|
import { buildHeadedUserAgent } from "./browser/executable/headed-user-agent.js";
|
|
5
3
|
import { resolve } from "node:path";
|
|
@@ -66,7 +64,7 @@ export class BrowserContext {
|
|
|
66
64
|
domain;
|
|
67
65
|
browserVersionString;
|
|
68
66
|
chromeFlags;
|
|
69
|
-
|
|
67
|
+
environment;
|
|
70
68
|
userAgent;
|
|
71
69
|
debuggingPort;
|
|
72
70
|
headless;
|
|
@@ -75,25 +73,25 @@ export class BrowserContext {
|
|
|
75
73
|
skArgs;
|
|
76
74
|
browserArgs;
|
|
77
75
|
chromePath;
|
|
78
|
-
constructor(domain, browserVersionString = "unknown", chromeFlags,
|
|
76
|
+
constructor(domain, browserVersionString = "unknown", chromeFlags, environment, userAgent, debuggingPort = false, headless = false, debugPort = 9222) {
|
|
79
77
|
this.domain = domain;
|
|
80
78
|
this.browserVersionString = browserVersionString;
|
|
81
79
|
this.chromeFlags = chromeFlags;
|
|
82
|
-
this.
|
|
80
|
+
this.environment = environment;
|
|
83
81
|
this.userAgent = userAgent;
|
|
84
82
|
this.debuggingPort = debuggingPort;
|
|
85
83
|
this.headless = headless;
|
|
86
84
|
this.debugPort = debugPort;
|
|
87
85
|
this.domain = domain;
|
|
88
86
|
this.chromeFlags = chromeFlags || [];
|
|
89
|
-
this.chromePath = resolve(
|
|
87
|
+
this.chromePath = resolve(environment.settings.chromePath);
|
|
90
88
|
// Copy: pushing onto the shared module-level array leaked args into every later instance.
|
|
91
89
|
const browserArguments = [...DEFAULT_BROWSER_ARGS];
|
|
92
|
-
if (
|
|
93
|
-
browserArguments.push(`--user-data-dir=${
|
|
90
|
+
if (environment?.settings.chromeUserProfilePath) {
|
|
91
|
+
browserArguments.push(`--user-data-dir=${environment?.settings.chromeUserProfilePath}`);
|
|
94
92
|
}
|
|
95
93
|
else {
|
|
96
|
-
const browserConfig = new BrowserConfig(this.
|
|
94
|
+
const browserConfig = new BrowserConfig(this.environment);
|
|
97
95
|
const temporaryProfileDirectory = browserConfig.loadProfileTempDir();
|
|
98
96
|
browserArguments.push(`--user-data-dir=${temporaryProfileDirectory}`);
|
|
99
97
|
}
|
|
@@ -130,14 +128,14 @@ export class BrowserContext {
|
|
|
130
128
|
return !!/chrome/i.test(this.browserVersionString);
|
|
131
129
|
}
|
|
132
130
|
getBrowserExtensionPath() {
|
|
133
|
-
if (this.
|
|
134
|
-
return this.
|
|
131
|
+
if (this.environment?.settings.chromeExtensionPaths) {
|
|
132
|
+
return this.environment.settings.chromeExtensionPaths.split(",");
|
|
135
133
|
}
|
|
136
134
|
return [];
|
|
137
135
|
}
|
|
138
136
|
/** The system-specific chromeFlags of the user config, appended to every other arg. */
|
|
139
137
|
getSystemChromeFlags() {
|
|
140
|
-
return this.
|
|
138
|
+
return this.environment?.settings.chromeFlags ?? [];
|
|
141
139
|
}
|
|
142
140
|
getFlagSources() {
|
|
143
141
|
return [
|
|
@@ -166,12 +164,12 @@ export class BrowserContext {
|
|
|
166
164
|
/** Args that depend on how Chrome is launched, added after the customer's chromeFlags. */
|
|
167
165
|
getLaunchOnlyArgs() {
|
|
168
166
|
const args = [];
|
|
169
|
-
if (this.
|
|
167
|
+
if (this.environment?.settings.chromeExtensionPaths) {
|
|
170
168
|
if (this.isChromeBrowser()) {
|
|
171
169
|
args.push("--remote-debugging-pipe");
|
|
172
170
|
}
|
|
173
171
|
else {
|
|
174
|
-
args.push(`--load-extension=${this.
|
|
172
|
+
args.push(`--load-extension=${this.environment?.settings.chromeExtensionPaths}`, `--disable-extensions-except=${this.environment?.settings.chromeExtensionPaths}`);
|
|
175
173
|
}
|
|
176
174
|
}
|
|
177
175
|
if (this.debuggingPort || this.headless) {
|
|
@@ -198,85 +196,19 @@ export class BrowserContext {
|
|
|
198
196
|
...(this.headless ? HEADLESS_DEFAULT_ARGS_TO_DROP : []),
|
|
199
197
|
],
|
|
200
198
|
};
|
|
201
|
-
if (this.
|
|
199
|
+
if (this.environment?.settings.chromeExtensionPaths &&
|
|
200
|
+
this.isChromeBrowser()) {
|
|
202
201
|
options["enableExtensions"] = this.getBrowserExtensionPath();
|
|
203
202
|
options["pipe"] = true;
|
|
204
203
|
}
|
|
205
204
|
return options;
|
|
206
205
|
}
|
|
207
206
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
ignoreContentSecurityPolicy;
|
|
214
|
-
cliPath;
|
|
215
|
-
verboseLevel;
|
|
216
|
-
useTestConfig;
|
|
217
|
-
debuggingPort;
|
|
218
|
-
headless;
|
|
219
|
-
debugPort;
|
|
220
|
-
browserFetch;
|
|
221
|
-
static flags = {
|
|
222
|
-
...CLI_CONFIG_NAME,
|
|
223
|
-
...CLI_CONFIG_IS_TEST,
|
|
224
|
-
[CLIParameters.Domain]: Flags.string({
|
|
225
|
-
char: CLIParametersChar.Domain,
|
|
226
|
-
description: "Startup domain (optional)",
|
|
227
|
-
}),
|
|
228
|
-
local: Flags.boolean({
|
|
229
|
-
char: "l",
|
|
230
|
-
default: false,
|
|
231
|
-
description: "Run with local documentHandler",
|
|
232
|
-
}),
|
|
233
|
-
debuggingPort: Flags.boolean({
|
|
234
|
-
char: "p",
|
|
235
|
-
default: false,
|
|
236
|
-
description: "Enable remote debugging port (disables speculation rules/prerendering)",
|
|
237
|
-
}),
|
|
238
|
-
debugPort: Flags.integer({
|
|
239
|
-
default: 9222,
|
|
240
|
-
description: "Chrome remote debugging port (only used with -p/--headless). Use distinct ports to run multiple onboarding processes at once.",
|
|
241
|
-
}),
|
|
242
|
-
verboseLevel: Flags.boolean({
|
|
243
|
-
char: "v",
|
|
244
|
-
default: false,
|
|
245
|
-
description: "Show all messages",
|
|
246
|
-
}),
|
|
247
|
-
ignoreContentSecurityPolicy: Flags.boolean({
|
|
248
|
-
char: "s",
|
|
249
|
-
default: false,
|
|
250
|
-
description: `Removes header/meta "content-security-policy" for origin-responses`,
|
|
251
|
-
}),
|
|
252
|
-
headless: Flags.boolean({
|
|
253
|
-
default: false,
|
|
254
|
-
description: "Run Chrome in headless mode (for CI environments). Implicitly enables remote debugging port.",
|
|
255
|
-
}),
|
|
256
|
-
browserFetch: Flags.boolean({
|
|
257
|
-
default: false,
|
|
258
|
-
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.",
|
|
259
|
-
}),
|
|
260
|
-
};
|
|
261
|
-
DEFAULT_DF_PATH = "https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js";
|
|
262
|
-
DEFAULT_DOCUMENT_HANDLER_PATH = "https://www.baqend.com/speed-kit-handler/latest/DocumentHandler.js";
|
|
263
|
-
DEFAULT_SNIPPET_PATH = "https://www.baqend.com/speed-kit/latest/snippet.js";
|
|
264
|
-
DEFAULT_SW_PATH = "https://www.baqend.com/speed-kit/latest/sw.js";
|
|
265
|
-
constructor(customerPath, configName, domain, local, ignoreContentSecurityPolicy = false, cliPath, verboseLevel, useTestConfig = false, debuggingPort = false, headless = false, debugPort = 9222, browserFetch = false) {
|
|
266
|
-
this.customerPath = customerPath;
|
|
267
|
-
this.configName = configName;
|
|
268
|
-
this.domain = domain;
|
|
269
|
-
this.local = local;
|
|
270
|
-
this.ignoreContentSecurityPolicy = ignoreContentSecurityPolicy;
|
|
271
|
-
this.cliPath = cliPath;
|
|
272
|
-
this.verboseLevel = verboseLevel;
|
|
273
|
-
this.useTestConfig = useTestConfig;
|
|
274
|
-
this.debuggingPort = debuggingPort;
|
|
275
|
-
this.headless = headless;
|
|
276
|
-
this.debugPort = debugPort;
|
|
277
|
-
this.browserFetch = browserFetch;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
207
|
+
/** Where the Speed Kit parts come from when a customer brings none of its own. */
|
|
208
|
+
export const DEFAULT_DF_PATH = "https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js";
|
|
209
|
+
export const DEFAULT_DOCUMENT_HANDLER_PATH = "https://www.baqend.com/speed-kit-handler/latest/DocumentHandler.js";
|
|
210
|
+
export const DEFAULT_SNIPPET_PATH = "https://www.baqend.com/speed-kit/latest/snippet.js";
|
|
211
|
+
export const DEFAULT_SW_PATH = "https://www.baqend.com/speed-kit/latest/sw.js";
|
|
280
212
|
export const USER_AGENT = {
|
|
281
213
|
DESKTOP: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15 (compatible; SpeedKit/1.0)",
|
|
282
214
|
MOBILE: "Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1 (compatible; SpeedKit/1.0)",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Interfaces } from "@oclif/core";
|
|
2
|
+
import { CliEnvironment, CommandContextValues } from "../cli/index.js";
|
|
3
|
+
declare const args: {
|
|
4
|
+
customerPath: Interfaces.Arg<string, {
|
|
5
|
+
exists?: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
};
|
|
8
|
+
declare const flags: {
|
|
9
|
+
domain: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
10
|
+
local: Interfaces.BooleanFlag<boolean>;
|
|
11
|
+
debuggingPort: Interfaces.BooleanFlag<boolean>;
|
|
12
|
+
debugPort: Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
|
|
13
|
+
verboseLevel: Interfaces.BooleanFlag<boolean>;
|
|
14
|
+
ignoreContentSecurityPolicy: Interfaces.BooleanFlag<boolean>;
|
|
15
|
+
headless: Interfaces.BooleanFlag<boolean>;
|
|
16
|
+
browserFetch: Interfaces.BooleanFlag<boolean>;
|
|
17
|
+
useTestConfig: Interfaces.BooleanFlag<boolean>;
|
|
18
|
+
configName: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
19
|
+
};
|
|
20
|
+
export interface OnboardingServiceBuildContextValues extends CommandContextValues {
|
|
21
|
+
readonly customerPath: string;
|
|
22
|
+
readonly configName: string;
|
|
23
|
+
readonly domain?: string;
|
|
24
|
+
readonly local: boolean;
|
|
25
|
+
readonly ignoreContentSecurityPolicy: boolean;
|
|
26
|
+
/** Where the CLI is installed, for the templates it ships. */
|
|
27
|
+
readonly cliPath: string;
|
|
28
|
+
readonly verboseLevel: boolean;
|
|
29
|
+
readonly useTestConfig: boolean;
|
|
30
|
+
readonly debuggingPort: boolean;
|
|
31
|
+
readonly headless: boolean;
|
|
32
|
+
readonly debugPort: number;
|
|
33
|
+
readonly browserFetch: boolean;
|
|
34
|
+
}
|
|
35
|
+
declare const OnboardingServiceBuildContext_base: new (values: OnboardingServiceBuildContextValues) => Readonly<OnboardingServiceBuildContextValues>;
|
|
36
|
+
/** What `sk onboarding` starts: a local Speed Kit dev environment for one customer. */
|
|
37
|
+
export declare class OnboardingServiceBuildContext extends OnboardingServiceBuildContext_base {
|
|
38
|
+
static readonly args: {
|
|
39
|
+
customerPath: Interfaces.Arg<string, {
|
|
40
|
+
exists?: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
static readonly flags: {
|
|
44
|
+
domain: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
45
|
+
local: Interfaces.BooleanFlag<boolean>;
|
|
46
|
+
debuggingPort: Interfaces.BooleanFlag<boolean>;
|
|
47
|
+
debugPort: Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
|
|
48
|
+
verboseLevel: Interfaces.BooleanFlag<boolean>;
|
|
49
|
+
ignoreContentSecurityPolicy: Interfaces.BooleanFlag<boolean>;
|
|
50
|
+
headless: Interfaces.BooleanFlag<boolean>;
|
|
51
|
+
browserFetch: Interfaces.BooleanFlag<boolean>;
|
|
52
|
+
useTestConfig: Interfaces.BooleanFlag<boolean>;
|
|
53
|
+
configName: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
54
|
+
};
|
|
55
|
+
static create(parsedArgs: Interfaces.InferredArgs<typeof args>, parsedFlags: Interfaces.InferredFlags<typeof flags>, environment: CliEnvironment): OnboardingServiceBuildContext;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Flags } from "@oclif/core";
|
|
2
|
+
import { CLI_CONFIG_IS_TEST, CLI_CONFIG_NAME, CLI_CUSTOMER_CONFIG, } from "../integration-api/customer-config-flags.js";
|
|
3
|
+
import { Context } from "../../models/context.js";
|
|
4
|
+
const args = { ...CLI_CUSTOMER_CONFIG };
|
|
5
|
+
const flags = {
|
|
6
|
+
...CLI_CONFIG_NAME,
|
|
7
|
+
...CLI_CONFIG_IS_TEST,
|
|
8
|
+
domain: Flags.string({
|
|
9
|
+
char: "d",
|
|
10
|
+
description: "Startup domain (optional)",
|
|
11
|
+
}),
|
|
12
|
+
local: Flags.boolean({
|
|
13
|
+
char: "l",
|
|
14
|
+
default: false,
|
|
15
|
+
description: "Run with local documentHandler",
|
|
16
|
+
}),
|
|
17
|
+
debuggingPort: Flags.boolean({
|
|
18
|
+
char: "p",
|
|
19
|
+
default: false,
|
|
20
|
+
description: "Enable remote debugging port (disables speculation rules/prerendering)",
|
|
21
|
+
}),
|
|
22
|
+
debugPort: Flags.integer({
|
|
23
|
+
default: 9222,
|
|
24
|
+
description: "Chrome remote debugging port (only used with -p/--headless). Use distinct ports to run multiple onboarding processes at once.",
|
|
25
|
+
}),
|
|
26
|
+
verboseLevel: Flags.boolean({
|
|
27
|
+
char: "v",
|
|
28
|
+
default: false,
|
|
29
|
+
description: "Show all messages",
|
|
30
|
+
}),
|
|
31
|
+
ignoreContentSecurityPolicy: Flags.boolean({
|
|
32
|
+
char: "s",
|
|
33
|
+
default: false,
|
|
34
|
+
description: `Removes header/meta "content-security-policy" for origin-responses`,
|
|
35
|
+
}),
|
|
36
|
+
headless: Flags.boolean({
|
|
37
|
+
default: false,
|
|
38
|
+
description: "Run Chrome in headless mode (for CI environments). Implicitly enables remote debugging port.",
|
|
39
|
+
}),
|
|
40
|
+
browserFetch: Flags.boolean({
|
|
41
|
+
default: false,
|
|
42
|
+
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.",
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
/** What `sk onboarding` starts: a local Speed Kit dev environment for one customer. */
|
|
46
|
+
export class OnboardingServiceBuildContext extends Context() {
|
|
47
|
+
static args = args;
|
|
48
|
+
static flags = flags;
|
|
49
|
+
static create(parsedArgs, parsedFlags, environment) {
|
|
50
|
+
return new OnboardingServiceBuildContext({
|
|
51
|
+
environment,
|
|
52
|
+
customerPath: parsedArgs.customerPath,
|
|
53
|
+
configName: parsedFlags.configName,
|
|
54
|
+
domain: parsedFlags["domain"],
|
|
55
|
+
local: parsedFlags.local,
|
|
56
|
+
ignoreContentSecurityPolicy: parsedFlags.ignoreContentSecurityPolicy,
|
|
57
|
+
cliPath: environment.oclif.root,
|
|
58
|
+
verboseLevel: parsedFlags.verboseLevel,
|
|
59
|
+
useTestConfig: parsedFlags.useTestConfig,
|
|
60
|
+
debuggingPort: parsedFlags.debuggingPort,
|
|
61
|
+
headless: parsedFlags.headless,
|
|
62
|
+
debugPort: parsedFlags.debugPort,
|
|
63
|
+
browserFetch: parsedFlags.browserFetch,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
OnboardingServiceBuildContext;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OnboardingContext } from "./onboarding-model.js";
|
|
1
|
+
import { OnboardingServiceBuildContext } from "./onboarding-service-build-context.js";
|
|
3
2
|
import { OnboardingService } from "./onboarding-service.js";
|
|
4
3
|
export declare class OnboardingServiceFactory {
|
|
5
4
|
private readonly context;
|
|
6
|
-
|
|
7
|
-
private cli?;
|
|
8
|
-
constructor(context: OnboardingContext, cliConfig: UserCliConfig, cli?: CliServiceInterface);
|
|
5
|
+
constructor(context: OnboardingServiceBuildContext);
|
|
9
6
|
getService(): Promise<OnboardingService>;
|
|
10
7
|
private prepareMessagehandler;
|
|
11
8
|
private getAppToken;
|
|
@@ -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";
|
|
@@ -42,19 +43,15 @@ import { ExtensionDownloader } from "./browser/extension/extension-downloader.js
|
|
|
42
43
|
import { ExecutableValidator } from "./browser/executable/executable-validator.js";
|
|
43
44
|
import { applyOriginProxy, withOriginProxyFlag, } from "../../helpers/origin-proxy.js";
|
|
44
45
|
import { QueryBuilderFactory } from "../query-builder/query-builder-factory.js";
|
|
45
|
-
import {
|
|
46
|
+
import { ParameterQueryServiceBuildContext } from "../query-builder/query-builder-service-build-context.js";
|
|
46
47
|
import { formatChromeFeatureFinding, formatChromeFlagDuplicate, } from "../../helpers/chrome-flags.js";
|
|
47
48
|
export class OnboardingServiceFactory {
|
|
48
49
|
context;
|
|
49
|
-
|
|
50
|
-
cli;
|
|
51
|
-
constructor(context, cliConfig, cli) {
|
|
50
|
+
constructor(context) {
|
|
52
51
|
this.context = context;
|
|
53
|
-
this.cliConfig = cliConfig;
|
|
54
|
-
this.cli = cli;
|
|
55
52
|
}
|
|
56
53
|
async getService() {
|
|
57
|
-
const cli = this.cli
|
|
54
|
+
const cli = this.context.environment.cli;
|
|
58
55
|
const files = await this.getIntegrationFiles(cli);
|
|
59
56
|
const customerConfig = files.getCustomerConfig().config;
|
|
60
57
|
// Before any origin request, so Chrome and the CLI agree on the route out.
|
|
@@ -62,7 +59,7 @@ export class OnboardingServiceFactory {
|
|
|
62
59
|
// Also before any origin request: an origin behind bot protection refuses the CLI outright,
|
|
63
60
|
// and `auto` only reaches for the browser once one actually has.
|
|
64
61
|
const browserFetch = installBrowserOriginFetch({
|
|
65
|
-
|
|
62
|
+
environment: this.context.environment,
|
|
66
63
|
logger: cli,
|
|
67
64
|
mode: this.context.browserFetch ? "always" : "auto",
|
|
68
65
|
});
|
|
@@ -71,22 +68,23 @@ export class OnboardingServiceFactory {
|
|
|
71
68
|
}
|
|
72
69
|
const domainToStart = await this.getUrlForTest(customerConfig, cli);
|
|
73
70
|
const cache = new Cache(cli);
|
|
74
|
-
const
|
|
71
|
+
const documentHandler = await new DocumentHandlerRuntimeServiceFactory(new DocumentHandlerRuntimeServiceBuildContext({
|
|
72
|
+
environment: this.context.environment,
|
|
75
73
|
configName: this.context.configName,
|
|
76
74
|
customerPath: this.context.customerPath,
|
|
77
75
|
verboseLevel: this.context.verboseLevel,
|
|
78
|
-
};
|
|
79
|
-
const documentHandler = await new DocumentHandlerRuntimeServiceFactory(documentHandlerContext, this.cliConfig, files, cli).buildDocumentHandlerServer();
|
|
76
|
+
}), files).buildDocumentHandlerServer();
|
|
80
77
|
const bundler = new BundleServiceFactory(this.context.customerPath).buildService();
|
|
81
78
|
const skTemplate = new InstallSpeedKitJsTemplate();
|
|
82
79
|
const speedKitInstallContext = new SpeedKitInstallContext(customerConfig, this.context.configName, files, bundler, skTemplate, this.context.local);
|
|
83
80
|
await this.buildInstallResource(speedKitInstallContext, files, cli);
|
|
84
|
-
const extensionDownloader = new ExtensionDownloader(this.
|
|
85
|
-
const browserExtensions = await new ExtensionValidator(extensionDownloader, this.
|
|
86
|
-
this.
|
|
87
|
-
|
|
81
|
+
const extensionDownloader = new ExtensionDownloader(this.context.environment, cli);
|
|
82
|
+
const browserExtensions = await new ExtensionValidator(extensionDownloader, this.context.environment, cli).getValidBrowserExtensions();
|
|
83
|
+
this.context.environment.settings.chromeExtensionPaths =
|
|
84
|
+
browserExtensions.paths.join(",");
|
|
85
|
+
const browserValidator = new ExecutableValidator(this.context.environment, cli);
|
|
88
86
|
const browserVersionString = await browserValidator.validateOrInstall();
|
|
89
|
-
const browserContext = new BrowserContext(domainToStart, browserVersionString, withOriginProxyFlag(customerConfig.chromeFlags), this.
|
|
87
|
+
const browserContext = new BrowserContext(domainToStart, browserVersionString, withOriginProxyFlag(customerConfig.chromeFlags), this.context.environment, undefined, this.context.debuggingPort, this.context.headless, this.context.debugPort);
|
|
90
88
|
for (const duplicate of browserContext.findDuplicateFlags()) {
|
|
91
89
|
cli.writeWarning(formatChromeFlagDuplicate(duplicate));
|
|
92
90
|
}
|
|
@@ -100,7 +98,7 @@ export class OnboardingServiceFactory {
|
|
|
100
98
|
cli.writeWarning("Running in headless mode.");
|
|
101
99
|
}
|
|
102
100
|
const fileWatcher = new FileWatcher(cli, customerConfig, files, documentHandler, browserContext, cache);
|
|
103
|
-
const athenaClient = (await this.getAthenaClient(customerConfig.app
|
|
101
|
+
const athenaClient = (await this.getAthenaClient(customerConfig.app)) || null;
|
|
104
102
|
const messageHandler = await this.prepareMessagehandler(athenaClient, files, customerConfig);
|
|
105
103
|
const speedKitServiceWorkerJs = new SpeedKitServiceWorkerJs(customerConfig, files.getByName(INTEGRATION_FILES.CUSTOM.SW));
|
|
106
104
|
const fetchHandler = await this.getFetchEventHandler(files, customerConfig, documentHandler, cache, cli, browserContext, athenaClient, messageHandler, fileWatcher, speedKitServiceWorkerJs);
|
|
@@ -112,7 +110,7 @@ export class OnboardingServiceFactory {
|
|
|
112
110
|
messageHandler.addMessage({
|
|
113
111
|
id: "skCli",
|
|
114
112
|
data: {
|
|
115
|
-
version: this.
|
|
113
|
+
version: this.context.environment.oclif.version,
|
|
116
114
|
app: customerConfig.app,
|
|
117
115
|
customerConfigPath: path.resolve(this.context.customerPath, this.context.configName),
|
|
118
116
|
},
|
|
@@ -154,8 +152,11 @@ export class OnboardingServiceFactory {
|
|
|
154
152
|
}
|
|
155
153
|
cli.failAction("ONBOARDING:BUILD:INSTALL_RESOURCE", result.error);
|
|
156
154
|
}
|
|
157
|
-
async getAthenaClient(app
|
|
158
|
-
const athenaFactory = new AthenaServiceFactory(
|
|
155
|
+
async getAthenaClient(app) {
|
|
156
|
+
const athenaFactory = new AthenaServiceFactory(new AthenaServiceBuildContext({
|
|
157
|
+
environment: this.context.environment,
|
|
158
|
+
app,
|
|
159
|
+
}));
|
|
159
160
|
const result = await safe(athenaFactory.getService());
|
|
160
161
|
if (result.success === true) {
|
|
161
162
|
return result.data;
|
|
@@ -169,12 +170,17 @@ export class OnboardingServiceFactory {
|
|
|
169
170
|
const configApi = this.getConfigApi(customerConfig.app);
|
|
170
171
|
const serverConfig = await this.getSpeedKitServerConfig(configApi, cli);
|
|
171
172
|
const crawler = new Crawler(cli, serverConfig);
|
|
172
|
-
const parameterQueryBuilder = await new QueryBuilderFactory({
|
|
173
|
+
const parameterQueryBuilder = await new QueryBuilderFactory(new ParameterQueryServiceBuildContext({
|
|
174
|
+
environment: this.context.environment,
|
|
173
175
|
configName: this.context.configName,
|
|
174
176
|
customerPath: this.context.customerPath,
|
|
175
|
-
isWindows: this.
|
|
176
|
-
}
|
|
177
|
-
const DiffService = new DiffServiceFactory(new
|
|
177
|
+
isWindows: this.context.environment.oclif.windows,
|
|
178
|
+
})).buildService();
|
|
179
|
+
const DiffService = new DiffServiceFactory(new DiffServiceBuildContext({
|
|
180
|
+
environment: this.context.environment,
|
|
181
|
+
executablePath: this.context.environment.settings.diffExec,
|
|
182
|
+
executableTemplate: this.context.environment.settings.diffExecTemplate,
|
|
183
|
+
})).getService();
|
|
178
184
|
const requestDiffService = new RequestDiffService(DiffService, documentHandler, cli);
|
|
179
185
|
const handlers = [
|
|
180
186
|
new CustomerDomainDocumentResponse(customerConfig, files.getByName(INTEGRATION_FILES.CONFIG.DYNAMIC_BLOCKS), files.getByName(INTEGRATION_FILES.CONFIG.DYNAMIC_STYLES), this.context.ignoreContentSecurityPolicy),
|
|
@@ -210,13 +216,20 @@ export class OnboardingServiceFactory {
|
|
|
210
216
|
const swPath = path.join(speedKitBuildPath, "sw.js");
|
|
211
217
|
const dfPath = path.join(speedKitBuildPath, "dynamic-fetcher.js");
|
|
212
218
|
const loaderPath = path.join(speedKitBuildPath, "snippet.js");
|
|
213
|
-
const integrationApiContext = new
|
|
214
|
-
|
|
219
|
+
const integrationApiContext = new IntegrationApiServiceBuildContext({
|
|
220
|
+
environment: this.context.environment,
|
|
221
|
+
basePath: this.context.customerPath,
|
|
222
|
+
configName: this.context.configName,
|
|
223
|
+
whitelist: [],
|
|
224
|
+
blockedFolders: [],
|
|
225
|
+
useTestConfig: this.context.useTestConfig,
|
|
226
|
+
});
|
|
227
|
+
const integrationApi = new IntegrationApiFactory(integrationApiContext).buildService();
|
|
215
228
|
const externalFileReader = new ExternalFileReader();
|
|
216
229
|
const integrationApiArray = [
|
|
217
230
|
{
|
|
218
231
|
name: INTEGRATION_FILES.CUSTOM.DOCUMENT_HANDLER,
|
|
219
|
-
recipe: new ExternalRecipe(
|
|
232
|
+
recipe: new ExternalRecipe(DEFAULT_DOCUMENT_HANDLER_PATH, externalFileReader),
|
|
220
233
|
},
|
|
221
234
|
];
|
|
222
235
|
// if speed-kit is npm-linked, use linked local files else fetch latest released sw and df
|
|
@@ -239,13 +252,13 @@ export class OnboardingServiceFactory {
|
|
|
239
252
|
else {
|
|
240
253
|
integrationApiArray.push({
|
|
241
254
|
name: INTEGRATION_FILES.CUSTOM.SW,
|
|
242
|
-
recipe: new ExternalRecipe(
|
|
255
|
+
recipe: new ExternalRecipe(DEFAULT_SW_PATH, externalFileReader),
|
|
243
256
|
}, {
|
|
244
257
|
name: INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER,
|
|
245
|
-
recipe: new ExternalRecipe(
|
|
258
|
+
recipe: new ExternalRecipe(DEFAULT_DF_PATH, externalFileReader),
|
|
246
259
|
}, {
|
|
247
260
|
name: INTEGRATION_FILES.CUSTOM.LOADER,
|
|
248
|
-
recipe: new ExternalRecipe(
|
|
261
|
+
recipe: new ExternalRecipe(DEFAULT_SNIPPET_PATH, externalFileReader),
|
|
249
262
|
});
|
|
250
263
|
}
|
|
251
264
|
return integrationApi.run(integrationApiArray);
|
|
@@ -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;
|