@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
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { IntegrationApiService } from "./integration-api-service.js";
|
|
2
|
-
import {
|
|
3
|
-
import { IntegrationApiContext } from "./integration-api-model.js";
|
|
2
|
+
import { IntegrationApiServiceBuildContext } from "./integration-api-service-build-context.js";
|
|
4
3
|
export declare class IntegrationApiFactory {
|
|
5
|
-
private context;
|
|
6
|
-
private cliConfig;
|
|
7
|
-
private cli?;
|
|
4
|
+
private readonly context;
|
|
8
5
|
service?: IntegrationApiService;
|
|
9
6
|
private fileReader?;
|
|
10
|
-
constructor(context:
|
|
7
|
+
constructor(context: IntegrationApiServiceBuildContext);
|
|
11
8
|
buildService(): IntegrationApiService;
|
|
12
9
|
private build;
|
|
10
|
+
private get whitelist();
|
|
13
11
|
private getFileReader;
|
|
14
12
|
}
|
|
@@ -7,19 +7,16 @@ import InstallResourceHandler from "./handler/install-resource-handler.js";
|
|
|
7
7
|
import ModuleHandler from "./handler/module-handler.js";
|
|
8
8
|
import ServerConfigHandler from "./handler/server-config-handler.js";
|
|
9
9
|
import FileWriter from "./file-writer.js";
|
|
10
|
-
import {
|
|
10
|
+
import { DEFAULT_BLOCKED_FILES, DEFAULT_BLOCKED_FOLDERS, } from "./integration-api-model.js";
|
|
11
11
|
import { VirtualFileHandler } from "./virtual/virtual-file-handler.js";
|
|
12
12
|
import fs from "node:fs";
|
|
13
|
+
import { BundleServiceFactory } from "../bundler/index.js";
|
|
13
14
|
export class IntegrationApiFactory {
|
|
14
15
|
context;
|
|
15
|
-
cliConfig;
|
|
16
|
-
cli;
|
|
17
16
|
service = undefined;
|
|
18
17
|
fileReader;
|
|
19
|
-
constructor(context
|
|
18
|
+
constructor(context) {
|
|
20
19
|
this.context = context;
|
|
21
|
-
this.cliConfig = cliConfig;
|
|
22
|
-
this.cli = cli;
|
|
23
20
|
}
|
|
24
21
|
buildService() {
|
|
25
22
|
if (!(this.service instanceof IntegrationApiService)) {
|
|
@@ -29,18 +26,21 @@ export class IntegrationApiFactory {
|
|
|
29
26
|
}
|
|
30
27
|
build() {
|
|
31
28
|
const fileReader = this.getFileReader();
|
|
32
|
-
const cli = this.cli
|
|
29
|
+
const cli = this.context.environment.cli;
|
|
33
30
|
const virtualFileHandler = new VirtualFileHandler(cli);
|
|
34
31
|
this.service = new IntegrationApiService(fileReader, virtualFileHandler, new MandatoryFilesValidator(), [
|
|
35
|
-
new CustomerConfigHandler(fileReader, cli, new CustomerConfigValidator(), this.context.configName, this.
|
|
36
|
-
new InstallResourceHandler(fileReader),
|
|
32
|
+
new CustomerConfigHandler(fileReader, cli, new CustomerConfigValidator(), this.context.configName, this.context.environment.settings.testApp, this.context.useTestConfig ?? false),
|
|
33
|
+
new InstallResourceHandler(fileReader, new BundleServiceFactory("./").buildService()),
|
|
37
34
|
new ServerConfigHandler(fileReader),
|
|
38
35
|
new ModuleHandler(fileReader),
|
|
39
|
-
], new FileWriter(fs, this.context.basePath), this.
|
|
36
|
+
], new FileWriter(fs, this.context.basePath), this.whitelist.length === 0);
|
|
37
|
+
}
|
|
38
|
+
get whitelist() {
|
|
39
|
+
return this.context.whitelist ?? [];
|
|
40
40
|
}
|
|
41
41
|
getFileReader() {
|
|
42
42
|
if (!this.fileReader) {
|
|
43
|
-
this.fileReader = new FileReader(fs, this.context.configName, this.context.basePath, this.
|
|
43
|
+
this.fileReader = new FileReader(fs, this.context.configName, this.context.basePath, this.whitelist, this.context.blockedFolders ?? DEFAULT_BLOCKED_FOLDERS, this.context.blockedFiles ?? DEFAULT_BLOCKED_FILES);
|
|
44
44
|
}
|
|
45
45
|
return this.fileReader;
|
|
46
46
|
}
|
|
@@ -109,12 +109,3 @@ export interface VirtualFileConfig {
|
|
|
109
109
|
}
|
|
110
110
|
export declare const DEFAULT_BLOCKED_FOLDERS: string[];
|
|
111
111
|
export declare const DEFAULT_BLOCKED_FILES: string[];
|
|
112
|
-
export declare class IntegrationApiContext {
|
|
113
|
-
readonly basePath: string;
|
|
114
|
-
readonly configName: string;
|
|
115
|
-
readonly whitelist: string[];
|
|
116
|
-
readonly blockedFolders: string[];
|
|
117
|
-
readonly useTestConfig: boolean;
|
|
118
|
-
readonly blockedFiles: string[];
|
|
119
|
-
constructor(basePath: string, configName: string, whitelist?: string[], blockedFolders?: string[], useTestConfig?: boolean, blockedFiles?: string[]);
|
|
120
|
-
}
|
|
@@ -32,19 +32,3 @@ export const DEFAULT_BLOCKED_FOLDERS = [
|
|
|
32
32
|
// "_pre-poc": parked pre-PoC files created by the graduation flow of
|
|
33
33
|
// generate-customer-config — kept for the manual merge, never deployed.
|
|
34
34
|
export const DEFAULT_BLOCKED_FILES = ["page-examples", "_pre-poc"];
|
|
35
|
-
export class IntegrationApiContext {
|
|
36
|
-
basePath;
|
|
37
|
-
configName;
|
|
38
|
-
whitelist;
|
|
39
|
-
blockedFolders;
|
|
40
|
-
useTestConfig;
|
|
41
|
-
blockedFiles;
|
|
42
|
-
constructor(basePath, configName, whitelist = [], blockedFolders = DEFAULT_BLOCKED_FOLDERS, useTestConfig = false, blockedFiles = DEFAULT_BLOCKED_FILES) {
|
|
43
|
-
this.basePath = basePath;
|
|
44
|
-
this.configName = configName;
|
|
45
|
-
this.whitelist = whitelist;
|
|
46
|
-
this.blockedFolders = blockedFolders;
|
|
47
|
-
this.useTestConfig = useTestConfig;
|
|
48
|
-
this.blockedFiles = blockedFiles;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CommandContextValues } from "../cli/index.js";
|
|
2
|
+
export interface IntegrationApiServiceBuildContextValues extends CommandContextValues {
|
|
3
|
+
/** The customer directory. */
|
|
4
|
+
readonly basePath: string;
|
|
5
|
+
/** Which block of config_customer to read. */
|
|
6
|
+
readonly configName: string;
|
|
7
|
+
/** Logical names of the files to load; empty or left out loads them all. */
|
|
8
|
+
readonly whitelist?: string[];
|
|
9
|
+
/** Folders never read; `DEFAULT_BLOCKED_FOLDERS` when left out. */
|
|
10
|
+
readonly blockedFolders?: string[];
|
|
11
|
+
readonly useTestConfig?: boolean;
|
|
12
|
+
/** Files never read; `DEFAULT_BLOCKED_FILES` when left out. */
|
|
13
|
+
readonly blockedFiles?: string[];
|
|
14
|
+
}
|
|
15
|
+
declare const IntegrationApiServiceBuildContext_base: new (values: IntegrationApiServiceBuildContextValues) => Readonly<IntegrationApiServiceBuildContextValues>;
|
|
16
|
+
/** Which customer directory the integration API reads, and how much of it. */
|
|
17
|
+
export declare class IntegrationApiServiceBuildContext extends IntegrationApiServiceBuildContext_base {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vm from "node:vm";
|
|
2
2
|
import { expect } from "chai";
|
|
3
3
|
import { describe, it } from "mocha";
|
|
4
|
-
import { SpeedKitConfig } from "../struct/speed-kit-config.js";
|
|
4
|
+
import { SpeedKitConfig, } from "../struct/speed-kit-config.js";
|
|
5
5
|
/**
|
|
6
6
|
* The plugin shapes here mirror the published bundles at
|
|
7
7
|
* `https://www.baqend.com/speed-kit-config/latest/`: a `name`, an `options`,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { BundleServiceFactory } from "../../bundler/index.js";
|
|
1
2
|
import { expect } from "chai";
|
|
2
3
|
import { after, before, describe, it } from "mocha";
|
|
3
4
|
import { VirtualFileHandler, } from "../integration-api-model.js";
|
|
4
5
|
import { IntegrationApiService } from "../integration-api-service.js";
|
|
5
6
|
import FileReader from "../file-reader.js";
|
|
6
7
|
import { fs, vol } from "memfs";
|
|
7
|
-
import { CliServiceFactory } from "../../cli/index.js";
|
|
8
|
+
import { CliServiceBuildContext, CliServiceFactory, } from "../../cli/index.js";
|
|
8
9
|
import FileWriter from "../file-writer.js";
|
|
9
10
|
import MandatoryFilesValidator from "../validator/mandatory-files-validator.js";
|
|
10
11
|
import CustomerConfigHandler from "../handler/customer-config-handler.js";
|
|
@@ -15,7 +16,10 @@ const afterTest = () => {
|
|
|
15
16
|
vol.reset();
|
|
16
17
|
};
|
|
17
18
|
function prepareDependencies() {
|
|
18
|
-
const cli = new CliServiceFactory(
|
|
19
|
+
const cli = new CliServiceFactory(new CliServiceBuildContext({
|
|
20
|
+
environment: { isCI: true, nonInteractive: true },
|
|
21
|
+
quiet: false,
|
|
22
|
+
})).getService();
|
|
19
23
|
const virtualFileHandler = new VirtualFileHandler(cli);
|
|
20
24
|
// @ts-expect-error fs is not compatible
|
|
21
25
|
const fileReader = new FileReader(fs, "test", "/test_customer", [], []);
|
|
@@ -23,7 +27,7 @@ function prepareDependencies() {
|
|
|
23
27
|
const validator = new MandatoryFilesValidator();
|
|
24
28
|
const customerConfigValidator = new CustomerConfigValidator();
|
|
25
29
|
const customerConfigHandler = new CustomerConfigHandler(fileReader, cli, customerConfigValidator, "test", "test");
|
|
26
|
-
const installResourceHandler = new InstallResourceHandler(fileReader);
|
|
30
|
+
const installResourceHandler = new InstallResourceHandler(fileReader, new BundleServiceFactory("./").buildService());
|
|
27
31
|
return {
|
|
28
32
|
virtualFileHandler,
|
|
29
33
|
fileReader,
|
|
@@ -2,8 +2,15 @@ import { expect } from "chai";
|
|
|
2
2
|
import { describe, it } from "mocha";
|
|
3
3
|
import { SpeedKitConfigFile, VirtualSpeedKitConfigFile } from "../index.js";
|
|
4
4
|
import { INTEGRATION_FILES } from "../../../models/files.js";
|
|
5
|
+
import { BundleServiceFactory } from "../../bundler/index.js";
|
|
6
|
+
const bundler = new BundleServiceFactory("./").buildService();
|
|
5
7
|
function configFile(source) {
|
|
6
|
-
return new SpeedKitConfigFile(
|
|
8
|
+
return new SpeedKitConfigFile({
|
|
9
|
+
name: INTEGRATION_FILES.CONFIG.SPEED_KIT,
|
|
10
|
+
path: "config_SpeedKit.js",
|
|
11
|
+
content: source,
|
|
12
|
+
remoteKey: "config",
|
|
13
|
+
}, bundler);
|
|
7
14
|
}
|
|
8
15
|
function evaluate(source) {
|
|
9
16
|
return configFile(source).evaluate("shop-de", "https://www.shop.de");
|
|
@@ -100,7 +107,7 @@ describe("SpeedKitConfigFile", () => {
|
|
|
100
107
|
});
|
|
101
108
|
it("should read the deployed config the same way as the local file", async () => {
|
|
102
109
|
const source = `window.speedKit = { split: 0.5, appName: APP };`;
|
|
103
|
-
const remote = await VirtualSpeedKitConfigFile.createRemote(source);
|
|
110
|
+
const remote = await VirtualSpeedKitConfigFile.createRemote(source, bundler);
|
|
104
111
|
const local = await evaluate(source);
|
|
105
112
|
const deployed = await remote.evaluate("shop-de", "https://www.shop.de");
|
|
106
113
|
expect(deployed).to.deep.equal(local);
|
|
@@ -24,7 +24,7 @@ import type { EvaluatedSpeedKitConfig } from "./speed-kit-config.js";
|
|
|
24
24
|
* here, or the query builder quietly goes back to reading half a config.
|
|
25
25
|
*/
|
|
26
26
|
/** A plugin instance as the evaluated config registered it. */
|
|
27
|
-
export type ConfigPluginLike = Record<string,
|
|
27
|
+
export type ConfigPluginLike = Record<string, unknown>;
|
|
28
28
|
export interface AppliedConfigPlugins {
|
|
29
29
|
/** The config as Speed Kit runs it: what the file wrote plus every hook. */
|
|
30
30
|
readonly config: EvaluatedSpeedKitConfig;
|
|
@@ -33,10 +33,10 @@ export function applyConfigPlugins(evaluated, plugins) {
|
|
|
33
33
|
// why a plugin declares its hooks as instance fields and its helpers on
|
|
34
34
|
// the prototype.
|
|
35
35
|
for (const key of Object.keys(plugin)) {
|
|
36
|
-
|
|
37
|
-
if (typeof hook !== "function") {
|
|
36
|
+
if (typeof plugin[key] !== "function") {
|
|
38
37
|
continue;
|
|
39
38
|
}
|
|
39
|
+
const hook = plugin[key];
|
|
40
40
|
if (key === APPLY_TO_CONFIG) {
|
|
41
41
|
deferred.push(hook);
|
|
42
42
|
contributed = true;
|
|
@@ -87,7 +87,8 @@ function getConfigValues(hook, configCopy, plugin) {
|
|
|
87
87
|
return value;
|
|
88
88
|
}
|
|
89
89
|
const name = pluginName(plugin);
|
|
90
|
-
const
|
|
90
|
+
const options = plugin.options;
|
|
91
|
+
const exclude = options?.exclude;
|
|
91
92
|
const rules = exclude ? applyExcludeTag(value, exclude, name) : value;
|
|
92
93
|
return prepareRules(rules, name);
|
|
93
94
|
}
|
|
@@ -119,7 +120,10 @@ function addDisabledScopes(modification, config) {
|
|
|
119
120
|
return;
|
|
120
121
|
}
|
|
121
122
|
const scopes = typeof modification === "string" ? [modification] : modification;
|
|
122
|
-
config.disabledScopes = [
|
|
123
|
+
config.disabledScopes = [
|
|
124
|
+
...(config.disabledScopes || []),
|
|
125
|
+
...scopes,
|
|
126
|
+
];
|
|
123
127
|
}
|
|
124
128
|
/** `speed-kit/snippet/configplugins/modifiers/addStripQueryParams.ts` */
|
|
125
129
|
function addStripQueryParams(modification, config) {
|
|
@@ -134,8 +138,9 @@ function addStripQueryParams(modification, config) {
|
|
|
134
138
|
// Conditions and rules must not be mixed: the service worker converts the
|
|
135
139
|
// whole property at once, so both sides become rules here.
|
|
136
140
|
const converted = toStripParamsRules(modification);
|
|
137
|
-
|
|
138
|
-
config.stripQueryParams
|
|
141
|
+
const rules = toStripParamsRules(config.stripQueryParams);
|
|
142
|
+
config.stripQueryParams = rules;
|
|
143
|
+
rules.push(...converted);
|
|
139
144
|
}
|
|
140
145
|
/** `speed-kit/snippet/configplugins/helpers/isTypeCondition.ts` */
|
|
141
146
|
function isCondition(value) {
|
|
@@ -231,7 +236,7 @@ function deepClone(value, sources = [], clones = []) {
|
|
|
231
236
|
clone.lastIndex = source.lastIndex;
|
|
232
237
|
return clone;
|
|
233
238
|
}
|
|
234
|
-
const out = Array.isArray(value) ? [] : {};
|
|
239
|
+
const out = (Array.isArray(value) ? [] : {});
|
|
235
240
|
sources.push(value);
|
|
236
241
|
clones.push(out);
|
|
237
242
|
for (const key of Object.keys(value)) {
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import type { BundleService } from "../../bundler/index.js";
|
|
1
2
|
import type { SpeedKitConfigInterface, VirtualFileInterface, VirtualFileRecipe } from "../integration-api-model.js";
|
|
2
3
|
import { InstallResourceFile } from "./install-resource-file.js";
|
|
3
4
|
import { SpeedKitConfig } from "./speed-kit-config.js";
|
|
4
5
|
/** The name the config deployed to the app is read back under. */
|
|
5
6
|
export declare const REMOTE_SPEED_KIT_CONFIG = "config_SpeedKit@remote";
|
|
7
|
+
/** The file a {@link SpeedKitConfigFile} stands for. */
|
|
8
|
+
export interface SpeedKitConfigFileInit {
|
|
9
|
+
name: string;
|
|
10
|
+
path: string;
|
|
11
|
+
content: string;
|
|
12
|
+
/** The key the file is uploaded under in the install resource. */
|
|
13
|
+
remoteKey: string;
|
|
14
|
+
}
|
|
6
15
|
/**
|
|
7
16
|
* `config_SpeedKit.js` — an install resource that can also read itself.
|
|
8
17
|
*
|
|
@@ -12,12 +21,18 @@ export declare const REMOTE_SPEED_KIT_CONFIG = "config_SpeedKit@remote";
|
|
|
12
21
|
* them through {@link evaluate}, so they all read the same config the same way.
|
|
13
22
|
*/
|
|
14
23
|
export declare class SpeedKitConfigFile extends InstallResourceFile implements SpeedKitConfigInterface {
|
|
24
|
+
private readonly bundler;
|
|
15
25
|
/**
|
|
16
26
|
* One evaluation per app and origin. A config branches on
|
|
17
27
|
* `window.location`, so the same file read for two origins is two different
|
|
18
28
|
* configs — and bundling one is expensive enough not to repeat per caller.
|
|
19
29
|
*/
|
|
20
30
|
private readonly evaluations;
|
|
31
|
+
/**
|
|
32
|
+
* @param file the file this config is read from
|
|
33
|
+
* @param bundler bundles the config source before it is run
|
|
34
|
+
*/
|
|
35
|
+
constructor(file: SpeedKitConfigFileInit, bundler: BundleService);
|
|
21
36
|
setContent(content: string): void;
|
|
22
37
|
/** The config this file describes for one app and origin. */
|
|
23
38
|
evaluate(app: string, origin: string): Promise<SpeedKitConfig>;
|
|
@@ -35,9 +50,10 @@ export declare class VirtualSpeedKitConfigFile extends SpeedKitConfigFile implem
|
|
|
35
50
|
* itself.
|
|
36
51
|
*
|
|
37
52
|
* @param content the `config` of the active install resource
|
|
53
|
+
* @param bundler bundles it before it is run, as for the local file
|
|
38
54
|
*/
|
|
39
|
-
static createRemote(content: string): Promise<VirtualSpeedKitConfigFile>;
|
|
40
|
-
constructor(name: string, recipe: VirtualFileRecipe, remoteKey?: string);
|
|
55
|
+
static createRemote(content: string, bundler: BundleService): Promise<VirtualSpeedKitConfigFile>;
|
|
56
|
+
constructor(name: string, recipe: VirtualFileRecipe, bundler: BundleService, remoteKey?: string);
|
|
41
57
|
buildContent(): Promise<void>;
|
|
42
58
|
updateFile(): Promise<void>;
|
|
43
59
|
updateIfChanged(): Promise<void>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as vm from "node:vm";
|
|
2
|
-
import { BundleServiceFactory } from "../../bundler/index.js";
|
|
3
2
|
import { EvaluateSkConfigError } from "../error/evaluate-sk-config-error.js";
|
|
4
3
|
import ApplicationError from "../../error-handling/error/application-error.js";
|
|
5
4
|
import { StaticRecipe } from "../virtual/static-recipe.js";
|
|
@@ -16,12 +15,21 @@ export const REMOTE_SPEED_KIT_CONFIG = "config_SpeedKit@remote";
|
|
|
16
15
|
* them through {@link evaluate}, so they all read the same config the same way.
|
|
17
16
|
*/
|
|
18
17
|
export class SpeedKitConfigFile extends InstallResourceFile {
|
|
18
|
+
bundler;
|
|
19
19
|
/**
|
|
20
20
|
* One evaluation per app and origin. A config branches on
|
|
21
21
|
* `window.location`, so the same file read for two origins is two different
|
|
22
22
|
* configs — and bundling one is expensive enough not to repeat per caller.
|
|
23
23
|
*/
|
|
24
24
|
evaluations = new Map();
|
|
25
|
+
/**
|
|
26
|
+
* @param file the file this config is read from
|
|
27
|
+
* @param bundler bundles the config source before it is run
|
|
28
|
+
*/
|
|
29
|
+
constructor(file, bundler) {
|
|
30
|
+
super(file.name, file.path, file.content, file.remoteKey);
|
|
31
|
+
this.bundler = bundler;
|
|
32
|
+
}
|
|
25
33
|
setContent(content) {
|
|
26
34
|
super.setContent(content);
|
|
27
35
|
this.evaluations.clear();
|
|
@@ -33,7 +41,9 @@ export class SpeedKitConfigFile extends InstallResourceFile {
|
|
|
33
41
|
if (cached) {
|
|
34
42
|
return cached;
|
|
35
43
|
}
|
|
36
|
-
const evaluation =
|
|
44
|
+
const evaluation = bundle(this.bundler, this.getContent(), app)
|
|
45
|
+
.then((code) => evaluateSpeedKitConfig(app, origin, code, this.path))
|
|
46
|
+
.catch((error) => {
|
|
37
47
|
// A failure is not an answer: forget it, so the next caller — or the
|
|
38
48
|
// next read after the file was fixed — evaluates again.
|
|
39
49
|
this.evaluations.delete(key);
|
|
@@ -56,14 +66,15 @@ export class VirtualSpeedKitConfigFile extends SpeedKitConfigFile {
|
|
|
56
66
|
* itself.
|
|
57
67
|
*
|
|
58
68
|
* @param content the `config` of the active install resource
|
|
69
|
+
* @param bundler bundles it before it is run, as for the local file
|
|
59
70
|
*/
|
|
60
|
-
static async createRemote(content) {
|
|
61
|
-
const file = new VirtualSpeedKitConfigFile(REMOTE_SPEED_KIT_CONFIG, new StaticRecipe(content));
|
|
71
|
+
static async createRemote(content, bundler) {
|
|
72
|
+
const file = new VirtualSpeedKitConfigFile(REMOTE_SPEED_KIT_CONFIG, new StaticRecipe(content), bundler);
|
|
62
73
|
await file.buildContent();
|
|
63
74
|
return file;
|
|
64
75
|
}
|
|
65
|
-
constructor(name, recipe, remoteKey = "config") {
|
|
66
|
-
super(name, name, "", remoteKey);
|
|
76
|
+
constructor(name, recipe, bundler, remoteKey = "config") {
|
|
77
|
+
super({ name, path: name, content: "", remoteKey }, bundler);
|
|
67
78
|
this.recipe = recipe;
|
|
68
79
|
}
|
|
69
80
|
async buildContent() {
|
|
@@ -83,17 +94,17 @@ export class VirtualSpeedKitConfigFile extends SpeedKitConfigFile {
|
|
|
83
94
|
}
|
|
84
95
|
}
|
|
85
96
|
/**
|
|
86
|
-
* Run a config
|
|
97
|
+
* Run a bundled config against a browser mock and hand back what it assigned to
|
|
87
98
|
* `window.speedKit`, together with the config plugins it registered.
|
|
88
99
|
*
|
|
89
100
|
* @param app the app the config is evaluated for, exposed to it as `APP`
|
|
90
101
|
* @param origin the origin the config is evaluated for, its `window.location`
|
|
91
|
-
* @param
|
|
102
|
+
* @param code the config source, bundled
|
|
92
103
|
* @param filename what an error in the config is reported under
|
|
93
104
|
*/
|
|
94
|
-
|
|
105
|
+
function evaluateSpeedKitConfig(app, origin, code, filename) {
|
|
95
106
|
const browserContext = buildBrowserMock(origin, app);
|
|
96
|
-
const fileContent = safeFileContentWrapper(
|
|
107
|
+
const fileContent = safeFileContentWrapper(code);
|
|
97
108
|
vm.runInNewContext(fileContent, browserContext, {
|
|
98
109
|
filename,
|
|
99
110
|
displayErrors: false,
|
|
@@ -203,11 +214,10 @@ function safeFileContentWrapper(fileContent) {
|
|
|
203
214
|
}
|
|
204
215
|
`;
|
|
205
216
|
}
|
|
206
|
-
async function bundle(content, app) {
|
|
217
|
+
async function bundle(bundler, content, app) {
|
|
207
218
|
if (!content) {
|
|
208
219
|
throw new ApplicationError("Content is empty");
|
|
209
220
|
}
|
|
210
|
-
const bundler = new BundleServiceFactory("./").buildService();
|
|
211
221
|
return bundler.bundle({
|
|
212
222
|
basePaths: {
|
|
213
223
|
"speed-kit-config": "https://www.baqend.com/speed-kit-config/latest/",
|
|
@@ -3,7 +3,7 @@ import { ConfigPluginLike } from "./config-plugin.js";
|
|
|
3
3
|
* The `window.speedKit` a config assigned, exactly as it wrote it — before
|
|
4
4
|
* anything has been made sense of.
|
|
5
5
|
*/
|
|
6
|
-
export type EvaluatedSpeedKitConfig = Record<string,
|
|
6
|
+
export type EvaluatedSpeedKitConfig = Record<string, unknown>;
|
|
7
7
|
/**
|
|
8
8
|
* One rule of a rule set.
|
|
9
9
|
*
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CliEnvironment } from "../../../cli/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* this class makes sure you always start skOnboarding with a fresh browser,
|
|
4
4
|
* but still keep your window/devtools-configuration
|
|
5
5
|
*/
|
|
6
6
|
export declare class BrowserConfig {
|
|
7
|
-
private
|
|
8
|
-
constructor(
|
|
7
|
+
private environment;
|
|
8
|
+
constructor(environment: CliEnvironment);
|
|
9
9
|
/**
|
|
10
10
|
* create a new temporary profileFolder
|
|
11
11
|
* load browserConfigJsonFile from last profileFolder
|
|
@@ -15,9 +15,9 @@ const keysToRemove = new Set([
|
|
|
15
15
|
* but still keep your window/devtools-configuration
|
|
16
16
|
*/
|
|
17
17
|
export class BrowserConfig {
|
|
18
|
-
|
|
19
|
-
constructor(
|
|
20
|
-
this.
|
|
18
|
+
environment;
|
|
19
|
+
constructor(environment) {
|
|
20
|
+
this.environment = environment;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* create a new temporary profileFolder
|
|
@@ -25,8 +25,8 @@ export class BrowserConfig {
|
|
|
25
25
|
* delete older profiles
|
|
26
26
|
*/
|
|
27
27
|
loadProfileTempDir() {
|
|
28
|
-
const chromeProfilePath = path.resolve(this.
|
|
29
|
-
const chromeProfilesParentFolderPath = path.resolve(this.
|
|
28
|
+
const chromeProfilePath = path.resolve(this.environment.cacheDir, chromeProfilesParentFolder, String(Date.now()));
|
|
29
|
+
const chromeProfilesParentFolderPath = path.resolve(this.environment.cacheDir, chromeProfilesParentFolder);
|
|
30
30
|
// create parentFolder if not exists
|
|
31
31
|
if (!fs.existsSync(chromeProfilesParentFolderPath)) {
|
|
32
32
|
fs.mkdirSync(chromeProfilesParentFolderPath, { recursive: true });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CliServiceInterface,
|
|
1
|
+
import { CliServiceInterface, CliEnvironment } from "../../../cli/index.js";
|
|
2
2
|
export declare class ExecutableValidator {
|
|
3
|
-
readonly
|
|
3
|
+
readonly environment: CliEnvironment;
|
|
4
4
|
private cli;
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(environment: CliEnvironment, cli: CliServiceInterface);
|
|
6
6
|
validateOrInstall(): Promise<string | undefined>;
|
|
7
7
|
private getCurrentBrowserVersion;
|
|
8
8
|
private getExecutablePathFromPuppeteer;
|
|
@@ -5,15 +5,15 @@ import ApplicationError from "../../../error-handling/error/application-error.js
|
|
|
5
5
|
import { Cache } from "@puppeteer/browsers";
|
|
6
6
|
import { resolve } from "node:path";
|
|
7
7
|
export class ExecutableValidator {
|
|
8
|
-
|
|
8
|
+
environment;
|
|
9
9
|
cli;
|
|
10
|
-
constructor(
|
|
11
|
-
this.
|
|
10
|
+
constructor(environment, cli) {
|
|
11
|
+
this.environment = environment;
|
|
12
12
|
this.cli = cli;
|
|
13
13
|
}
|
|
14
14
|
async validateOrInstall() {
|
|
15
15
|
// check if a valid browserExecutablePath is configured
|
|
16
|
-
const userChromePath = this.
|
|
16
|
+
const userChromePath = this.environment?.settings.chromePath;
|
|
17
17
|
if (this.isValidBrowserExecutable()) {
|
|
18
18
|
return this.getCurrentBrowserVersion();
|
|
19
19
|
}
|
|
@@ -22,11 +22,12 @@ export class ExecutableValidator {
|
|
|
22
22
|
this.cli.writeError(`Invalid "chromePath" configured: ${userChromePath}`);
|
|
23
23
|
}
|
|
24
24
|
// check if a browser is installed via puppeteer
|
|
25
|
-
const puppeteerCache = new Cache(this.
|
|
25
|
+
const puppeteerCache = new Cache(this.environment.cacheDir);
|
|
26
26
|
const installedBrowsers = puppeteerCache.getInstalledBrowsers();
|
|
27
27
|
if (installedBrowsers.length > 0) {
|
|
28
28
|
// found an installed browser, set path to this
|
|
29
|
-
this.
|
|
29
|
+
this.environment.settings.chromePath =
|
|
30
|
+
installedBrowsers[0].executablePath;
|
|
30
31
|
return this.getCurrentBrowserVersion();
|
|
31
32
|
}
|
|
32
33
|
// write warning that no browser is configured
|
|
@@ -38,7 +39,7 @@ export class ExecutableValidator {
|
|
|
38
39
|
// @todo set more detailed error message here.
|
|
39
40
|
if (!result) {
|
|
40
41
|
throw new ApplicationError("No Browser found to use", [
|
|
41
|
-
`set path to browser executable (chromePath) in ${this.
|
|
42
|
+
`set path to browser executable (chromePath) in ${this.environment.oclif.configDir}/config.json`,
|
|
42
43
|
`set path to browser executable (CHROME_PATH) in ./.env or as systemwide env`,
|
|
43
44
|
`let the ci download the latest chrome for you`,
|
|
44
45
|
]);
|
|
@@ -46,7 +47,8 @@ export class ExecutableValidator {
|
|
|
46
47
|
// use puppeteerCli to download chrome
|
|
47
48
|
await this.installBrowser();
|
|
48
49
|
// set path to freshly installed chrome
|
|
49
|
-
this.
|
|
50
|
+
this.environment.settings.chromePath =
|
|
51
|
+
this.getExecutablePathFromPuppeteer();
|
|
50
52
|
return this.getCurrentBrowserVersion();
|
|
51
53
|
}
|
|
52
54
|
getCurrentBrowserVersion() {
|
|
@@ -54,23 +56,23 @@ export class ExecutableValidator {
|
|
|
54
56
|
// so we use a powershell instead. Emit `<ProductName> <FileVersion>` so the
|
|
55
57
|
// output is shape-compatible with `chrome --version` on macOS/Linux —
|
|
56
58
|
// downstream consumers (isChromeBrowser, log lines) can stay OS-agnostic.
|
|
57
|
-
if (this.
|
|
58
|
-
return this.cli.execSync(`$i = (Get-Item '${this.
|
|
59
|
+
if (this.environment.oclif.windows) {
|
|
60
|
+
return this.cli.execSync(`$i = (Get-Item '${this.environment.settings.chromePath}').VersionInfo; "$($i.ProductName) $($i.FileVersion)"`, { shell: "powershell.exe" });
|
|
59
61
|
}
|
|
60
|
-
return this.cli.execSync(`"${this.
|
|
62
|
+
return this.cli.execSync(`"${this.environment.settings.chromePath}" --version`);
|
|
61
63
|
}
|
|
62
64
|
getExecutablePathFromPuppeteer() {
|
|
63
|
-
const puppeteerCache = new Cache(this.
|
|
65
|
+
const puppeteerCache = new Cache(this.environment.cacheDir);
|
|
64
66
|
const installedBrowsers = puppeteerCache.getInstalledBrowsers();
|
|
65
67
|
return installedBrowsers[0].executablePath;
|
|
66
68
|
}
|
|
67
69
|
isValidBrowserExecutable() {
|
|
68
|
-
return (this.
|
|
69
|
-
existsSync(resolve(this.
|
|
70
|
+
return (this.environment?.settings.chromePath.length > 0 &&
|
|
71
|
+
existsSync(resolve(this.environment?.settings.chromePath.trim())));
|
|
70
72
|
}
|
|
71
73
|
async installBrowser() {
|
|
72
74
|
const puppeteerCli = new CLI({
|
|
73
|
-
cachePath: this.
|
|
75
|
+
cachePath: this.environment.cacheDir,
|
|
74
76
|
scriptName: "@puppeteer/browsers",
|
|
75
77
|
prefixCommand: {
|
|
76
78
|
cmd: "browsers",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CliServiceInterface,
|
|
1
|
+
import { CliServiceInterface, CliEnvironment } from "../../../cli/index.js";
|
|
2
2
|
interface DevtoolsInstallOptions {
|
|
3
3
|
/** ask before installing or updating, off for an explicit install command */
|
|
4
4
|
confirm?: boolean;
|
|
@@ -12,9 +12,9 @@ export interface DevtoolsInstallResult {
|
|
|
12
12
|
status: "installed" | "updated" | "up-to-date" | "kept" | "declined" | "failed";
|
|
13
13
|
}
|
|
14
14
|
export declare class ExtensionDownloader {
|
|
15
|
-
private
|
|
15
|
+
private environment;
|
|
16
16
|
private cli;
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(environment: CliEnvironment, cli: CliServiceInterface);
|
|
18
18
|
/**
|
|
19
19
|
* path of the devtools extension to load, or undefined when there is none
|
|
20
20
|
*/
|
|
@@ -5,10 +5,10 @@ import extract from "extract-zip";
|
|
|
5
5
|
import { safe } from "../../../../helpers/safe.js";
|
|
6
6
|
const devtools = "integration-devtools";
|
|
7
7
|
export class ExtensionDownloader {
|
|
8
|
-
|
|
8
|
+
environment;
|
|
9
9
|
cli;
|
|
10
|
-
constructor(
|
|
11
|
-
this.
|
|
10
|
+
constructor(environment, cli) {
|
|
11
|
+
this.environment = environment;
|
|
12
12
|
this.cli = cli;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
@@ -62,7 +62,7 @@ export class ExtensionDownloader {
|
|
|
62
62
|
return result;
|
|
63
63
|
}
|
|
64
64
|
get installedPath() {
|
|
65
|
-
return path.resolve(this.
|
|
65
|
+
return path.resolve(this.environment.cacheDir, devtools);
|
|
66
66
|
}
|
|
67
67
|
async installLatest(status) {
|
|
68
68
|
this.cli.startAction("ONBOARDING:UPDATE:DEVTOOLS", "update integration-devtools");
|
|
@@ -87,14 +87,14 @@ export class ExtensionDownloader {
|
|
|
87
87
|
}
|
|
88
88
|
// resolve path for zipFile, it is removed after extraction, so its name
|
|
89
89
|
// does not depend on the response
|
|
90
|
-
const archivePath = path.resolve(this.
|
|
90
|
+
const archivePath = path.resolve(this.environment.cacheDir, `${devtools}.zip`);
|
|
91
91
|
// extract next to the installed version, which is only replaced once
|
|
92
92
|
// extraction is complete
|
|
93
93
|
const stagingPath = `${this.installedPath}.download`;
|
|
94
94
|
// getFileBlob
|
|
95
95
|
const extensionBlob = await extensionResponse.bytes();
|
|
96
96
|
assertZipArchive(extensionBlob, extensionResponse);
|
|
97
|
-
fs.mkdirSync(this.
|
|
97
|
+
fs.mkdirSync(this.environment.cacheDir, { recursive: true });
|
|
98
98
|
// write zipFile
|
|
99
99
|
fs.writeFileSync(archivePath, extensionBlob);
|
|
100
100
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CliServiceInterface,
|
|
1
|
+
import { CliServiceInterface, CliEnvironment } from "../../../cli/index.js";
|
|
2
2
|
import { ExtensionDownloader } from "./extension-downloader.js";
|
|
3
3
|
export interface BrowserExtensions {
|
|
4
4
|
paths: string[];
|
|
@@ -7,9 +7,9 @@ export interface BrowserExtensions {
|
|
|
7
7
|
}
|
|
8
8
|
export declare class ExtensionValidator {
|
|
9
9
|
private extensionDownloader;
|
|
10
|
-
private
|
|
10
|
+
private environment;
|
|
11
11
|
private cli;
|
|
12
|
-
constructor(extensionDownloader: ExtensionDownloader,
|
|
12
|
+
constructor(extensionDownloader: ExtensionDownloader, environment: CliEnvironment, cli: CliServiceInterface);
|
|
13
13
|
getValidBrowserExtensions(): Promise<BrowserExtensions>;
|
|
14
14
|
/**
|
|
15
15
|
* manifest of a configured extension path. One inside a local npm project
|