@speedkit/cli 4.44.0-beta.4 → 4.44.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -13
- package/README.md +68 -42
- package/dist/base/sk-command.d.ts +7 -0
- package/dist/base/sk-command.js +19 -0
- package/dist/commands/deploy.d.ts +1 -0
- package/dist/commands/deploy.js +5 -1
- package/dist/commands/diff.d.ts +47 -0
- package/dist/commands/diff.js +67 -0
- package/dist/commands/generate-pop-config.js +3 -7
- package/dist/helpers/race.js +4 -2
- package/dist/helpers/spec/race.spec.js +31 -0
- package/dist/models/files.d.ts +0 -1
- package/dist/models/files.js +0 -1
- package/dist/services/browser-fetch/browser-origin-fetch.js +1 -1
- package/dist/services/browser-fetch/browser-origin-fetcher.d.ts +1 -7
- package/dist/services/browser-fetch/browser-origin-fetcher.js +3 -26
- package/dist/services/bundler/bundle-service-factory.d.ts +0 -3
- package/dist/services/bundler/bundle-service-factory.js +1 -5
- package/dist/services/bundler/bundle-service.d.ts +1 -10
- package/dist/services/bundler/bundle-service.js +1 -16
- package/dist/services/bundler/index.d.ts +0 -1
- package/dist/services/bundler/index.js +0 -1
- package/dist/services/cli/cli-environment.d.ts +11 -0
- package/dist/services/cli/cli-environment.js +37 -0
- package/dist/services/cli/cli-service-model.d.ts +3 -1
- package/dist/services/cli/cli-service.d.ts +1 -1
- package/dist/services/cli/cli-service.js +4 -1
- package/dist/services/cli/spec/cli-environment.spec.js +30 -1
- package/dist/services/deploy/checks/activation/customer-approval-check.js +1 -1
- package/dist/services/deploy/checks/post-deploy/refresh-deployment-job-check.d.ts +2 -2
- package/dist/services/deploy/checks/post-deploy/refresh-deployment-job-check.js +8 -7
- package/dist/services/deploy/checks/post-deploy/revalidated-module-check.d.ts +2 -2
- package/dist/services/deploy/checks/post-deploy/revalidated-module-check.js +11 -7
- package/dist/services/deploy/checks/post-deploy/save-files-check.d.ts +2 -2
- package/dist/services/deploy/checks/post-deploy/save-files-check.js +3 -2
- package/dist/services/deploy/checks/pre-deploy/device-detection-changed-check.js +3 -2
- package/dist/services/deploy/checks/pre-deploy/split-change-check.js +3 -2
- package/dist/services/deploy/deploy-service-build-context.d.ts +2 -0
- package/dist/services/deploy/deploy-service-build-context.js +13 -2
- package/dist/services/deploy/deploy-service-factory.js +2 -9
- package/dist/services/deploy/deploy-service-model.d.ts +11 -1
- package/dist/services/deploy/deploy-service.d.ts +2 -0
- package/dist/services/deploy/deploy-service.js +26 -1
- package/dist/services/deploy/handler/customer-config-handler.d.ts +2 -2
- package/dist/services/deploy/handler/install-resource-handler.d.ts +2 -2
- package/dist/services/deploy/handler/install-resource-handler.js +6 -3
- package/dist/services/deploy/handler/module-handler.d.ts +2 -2
- package/dist/services/deploy/handler/module-handler.js +2 -2
- package/dist/services/deploy/handler/server-config-handler.d.ts +2 -2
- package/dist/services/deploy/handler/server-config-handler.js +2 -2
- package/dist/services/deploy/mr/live-state-check.d.ts +2 -2
- package/dist/services/deploy/mr/merge-request-deploy-service-factory.js +2 -7
- package/dist/services/deploy/policy/deploy-policy-model.d.ts +1 -5
- package/dist/services/deploy/policy/deploy-policy-model.js +0 -4
- package/dist/services/deploy/policy/index.d.ts +1 -0
- package/dist/services/deploy/policy/index.js +1 -0
- package/dist/services/deploy/policy/testing-deploy-policy.d.ts +16 -0
- package/dist/services/deploy/policy/testing-deploy-policy.js +42 -0
- package/dist/services/deploy/spec/checks/post-deploy/refresh-deployment-job-check.spec.js +5 -12
- package/dist/services/deploy/spec/deploy-service.spec.js +64 -0
- package/dist/services/deploy/spec/handler/install-resource-handler.spec.js +58 -0
- package/dist/services/deploy/spec/mr/live-state-check.spec.js +2 -2
- package/dist/services/deploy/spec/policy/auto-deploy-policy.spec.js +0 -2
- package/dist/services/deploy/spec/policy/testing-deploy-policy.spec.d.ts +1 -0
- package/dist/services/deploy/spec/policy/testing-deploy-policy.spec.js +46 -0
- package/dist/services/diff/create-diff-engine.d.ts +14 -0
- package/dist/services/diff/create-diff-engine.js +42 -0
- package/dist/services/diff/customer-origin.d.ts +9 -0
- package/dist/services/diff/customer-origin.js +19 -0
- package/dist/services/diff/diff-engine.d.ts +30 -0
- package/dist/services/diff/diff-engine.js +49 -0
- package/dist/services/diff/diff-log.d.ts +9 -0
- package/dist/services/diff/diff-log.js +18 -0
- package/dist/services/diff/diff-model.d.ts +68 -0
- package/dist/services/diff/diff-model.js +1 -0
- package/dist/services/diff/diff-service-build-context.d.ts +99 -9
- package/dist/services/diff/diff-service-build-context.js +299 -1
- package/dist/services/diff/diff-service-factory.d.ts +24 -2
- package/dist/services/diff/diff-service-factory.js +165 -3
- package/dist/services/diff/diff-service.d.ts +93 -33
- package/dist/services/diff/diff-service.js +274 -140
- package/dist/services/diff/index.d.ts +12 -1
- package/dist/services/diff/index.js +12 -1
- package/dist/services/diff/noise-baseline.d.ts +28 -0
- package/dist/services/diff/noise-baseline.js +105 -0
- package/dist/services/diff/page-source.d.ts +42 -0
- package/dist/services/diff/page-source.js +93 -0
- package/dist/services/diff/side-failure.d.ts +28 -0
- package/dist/services/diff/side-failure.js +100 -0
- package/dist/services/diff/sinks/json-diff-sink.d.ts +32 -0
- package/dist/services/diff/sinks/json-diff-sink.js +44 -0
- package/dist/services/diff/sinks/no-diff-sink.d.ts +5 -0
- package/dist/services/diff/sinks/no-diff-sink.js +6 -0
- package/dist/services/diff/sinks/patch-diff-sink.d.ts +19 -0
- package/dist/services/diff/sinks/patch-diff-sink.js +29 -0
- package/dist/services/diff/sinks/tool-diff-sink.d.ts +26 -0
- package/dist/services/diff/sinks/tool-diff-sink.js +88 -0
- package/dist/services/diff/sinks/unified-patch.d.ts +7 -0
- package/dist/services/diff/sinks/unified-patch.js +12 -0
- package/dist/services/diff/spec/customer-origin.spec.d.ts +1 -0
- package/dist/services/diff/spec/customer-origin.spec.js +27 -0
- package/dist/services/diff/spec/diff-engine.spec.d.ts +1 -0
- package/dist/services/diff/spec/diff-engine.spec.js +47 -0
- package/dist/services/diff/spec/diff-service-build-context.spec.d.ts +1 -0
- package/dist/services/diff/spec/diff-service-build-context.spec.js +185 -0
- package/dist/services/diff/spec/diff-service.spec.d.ts +1 -0
- package/dist/services/diff/spec/diff-service.spec.js +393 -0
- package/dist/services/diff/spec/noise-baseline.spec.d.ts +1 -0
- package/dist/services/diff/spec/noise-baseline.spec.js +95 -0
- package/dist/services/diff/spec/page-source.spec.d.ts +1 -0
- package/dist/services/diff/spec/page-source.spec.js +140 -0
- package/dist/services/diff/spec/sinks/json-diff-sink.spec.d.ts +1 -0
- package/dist/services/diff/spec/sinks/json-diff-sink.spec.js +72 -0
- package/dist/services/diff/spec/sinks/patch-diff-sink.spec.d.ts +1 -0
- package/dist/services/diff/spec/sinks/patch-diff-sink.spec.js +47 -0
- package/dist/services/diff/spec/sinks/tool-diff-sink.spec.d.ts +1 -0
- package/dist/services/diff/spec/sinks/tool-diff-sink.spec.js +61 -0
- package/dist/services/document-handler-runtime/document-handler-abort.d.ts +2 -0
- package/dist/services/document-handler-runtime/document-handler-abort.js +2 -0
- package/dist/services/document-handler-runtime/document-handler-server.d.ts +0 -17
- package/dist/services/document-handler-runtime/document-handler-server.js +19 -81
- package/dist/services/document-handler-runtime/runtime-files.d.ts +9 -0
- package/dist/services/document-handler-runtime/runtime-files.js +17 -0
- package/dist/services/integration-api/integration-api-model.d.ts +1 -2
- package/dist/services/integration-api/spec/speed-kit-config-file.spec.js +8 -68
- package/dist/services/integration-api/struct/customer-config.d.ts +1 -32
- package/dist/services/integration-api/struct/customer-config.js +3 -33
- package/dist/services/integration-api/struct/speed-kit-config-file.d.ts +4 -9
- package/dist/services/integration-api/struct/speed-kit-config-file.js +10 -27
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +8 -25
- package/dist/services/onboarding/dashboard/diff-against-current-page.d.ts +29 -7
- package/dist/services/onboarding/dashboard/diff-against-current-page.js +24 -37
- package/dist/services/onboarding/dashboard/index.js +13 -6
- package/dist/services/onboarding/dashboard/request-diff-service.d.ts +21 -8
- package/dist/services/onboarding/dashboard/request-diff-service.js +21 -49
- package/dist/services/onboarding/onboarding-model.d.ts +0 -1
- package/dist/services/onboarding/onboarding-model.js +0 -1
- package/dist/services/onboarding/onboarding-service-factory.d.ts +0 -1
- package/dist/services/onboarding/onboarding-service-factory.js +24 -30
- package/dist/services/onboarding/spec/dashboard/request-diff-service.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/dashboard/request-diff-service.spec.js +57 -0
- package/dist/services/onboarding/templates/install-speed-kit-js-template.js +0 -5
- package/dist/services/onboarding/virtual-orestes-app/index.d.ts +3 -3
- package/dist/services/onboarding/virtual-orestes-app/index.js +5 -5
- package/dist/services/origin-request/index.d.ts +3 -0
- package/dist/services/origin-request/index.js +3 -0
- package/dist/services/origin-request/origin-fetcher.d.ts +52 -0
- package/dist/services/origin-request/origin-fetcher.js +93 -0
- package/dist/services/origin-request/origin-request-service-factory.js +19 -1
- package/dist/services/origin-request/origin-request-service.d.ts +6 -10
- package/dist/services/origin-request/origin-request-service.js +28 -70
- package/dist/services/origin-request/runtime-config-source.d.ts +36 -0
- package/dist/services/origin-request/runtime-config-source.js +59 -0
- package/dist/services/origin-request/spec/origin-error-cause.spec.d.ts +1 -0
- package/dist/services/{onboarding/spec/virtual-orestes-app → origin-request/spec}/origin-error-cause.spec.js +1 -1
- package/dist/services/origin-request/spec/origin-fetcher.spec.d.ts +1 -0
- package/dist/services/{onboarding/spec/virtual-orestes-app/crawler.spec.js → origin-request/spec/origin-fetcher.spec.js} +46 -15
- package/dist/services/prewarm/assets/asset-api-client.d.ts +6 -0
- package/dist/services/prewarm/assets/asset-api-client.js +6 -1
- package/dist/services/prewarm/pre-warm-service.d.ts +10 -0
- package/dist/services/prewarm/pre-warm-service.js +17 -0
- package/dist/services/prewarm/spec/pre-warm-service.spec.d.ts +1 -0
- package/dist/services/prewarm/spec/pre-warm-service.spec.js +72 -0
- package/dist/services/query-builder/query-builder-factory.js +3 -3
- package/dist/services/setup/os/tool-registry.d.ts +1 -1
- package/oclif.manifest.json +151 -19
- package/package.json +1 -2
- package/dist/commands/diff-url-parameters.d.ts +0 -19
- package/dist/commands/diff-url-parameters.js +0 -121
- package/dist/services/bundler/error/packjockel-error.d.ts +0 -3
- package/dist/services/bundler/error/packjockel-error.js +0 -3
- package/dist/services/bundler/packjockel-service.d.ts +0 -72
- package/dist/services/bundler/packjockel-service.js +0 -156
- package/dist/services/bundler/spec/packjockel-service.spec.js +0 -143
- package/dist/services/deploy/checks/post-deploy/deprecated-deployment-detection-check.d.ts +0 -15
- package/dist/services/deploy/checks/post-deploy/deprecated-deployment-detection-check.js +0 -70
- package/dist/services/deploy/error/check-module-file-error.d.ts +0 -4
- package/dist/services/deploy/error/check-module-file-error.js +0 -4
- package/dist/services/deploy/error/post-deploy-deployment-detection-error.d.ts +0 -4
- package/dist/services/deploy/error/post-deploy-deployment-detection-error.js +0 -4
- package/dist/services/onboarding/server-config/index.d.ts +0 -10
- package/dist/services/onboarding/server-config/index.js +0 -27
- package/dist/services/onboarding/virtual-orestes-app/crawler.d.ts +0 -31
- package/dist/services/onboarding/virtual-orestes-app/crawler.js +0 -98
- /package/dist/{services/bundler/spec/packjockel-service.spec.d.ts → helpers/spec/race.spec.d.ts} +0 -0
- /package/dist/services/{onboarding/spec/virtual-orestes-app/crawler.spec.d.ts → deploy/spec/deploy-service.spec.d.ts} +0 -0
- /package/dist/services/{onboarding/spec/virtual-orestes-app/origin-error-cause.spec.d.ts → deploy/spec/handler/install-resource-handler.spec.d.ts} +0 -0
- /package/dist/services/{onboarding/virtual-orestes-app → origin-request}/origin-error-cause.d.ts +0 -0
- /package/dist/services/{onboarding/virtual-orestes-app → origin-request}/origin-error-cause.js +0 -0
|
@@ -1,15 +1,177 @@
|
|
|
1
|
+
import { applyOriginProxy } from "../../helpers/origin-proxy.js";
|
|
2
|
+
import { installBrowserOriginFetch } from "../browser-fetch/index.js";
|
|
3
|
+
import { ConfigApiContext, ConfigApiServiceFactory, } from "../config-api/index.js";
|
|
4
|
+
import { DocumentHandlerRuntimeServiceBuildContext } from "../document-handler-runtime/document-handler-runtime-service-build-context.js";
|
|
5
|
+
import DocumentHandlerRuntimeServiceFactory from "../document-handler-runtime/factory/document-handler-runtime-service-factory.js";
|
|
6
|
+
import { documentHandlerRuntimeFiles } from "../document-handler-runtime/runtime-files.js";
|
|
7
|
+
import ApplicationError from "../error-handling/error/application-error.js";
|
|
8
|
+
import { IntegrationApiFactory, IntegrationApiServiceBuildContext, } from "../integration-api/index.js";
|
|
9
|
+
import { DEFAULT_TYPE, OriginFetcher, RuntimeConfigSource, } from "../origin-request/index.js";
|
|
10
|
+
import { createDiffEngine } from "./create-diff-engine.js";
|
|
11
|
+
import { assertCustomerOrigin } from "./customer-origin.js";
|
|
12
|
+
import { stderrLog } from "./diff-log.js";
|
|
13
|
+
import { variationPair, } from "./diff-service-build-context.js";
|
|
1
14
|
import { DiffService } from "./diff-service.js";
|
|
15
|
+
import { PageSource } from "./page-source.js";
|
|
16
|
+
/**
|
|
17
|
+
* The variations a person can choose from: the device variations and the
|
|
18
|
+
* runtime config's named ones. A template, which needs a value filled in,
|
|
19
|
+
* has to be named.
|
|
20
|
+
*/
|
|
21
|
+
function variationChoices(variations) {
|
|
22
|
+
const names = [
|
|
23
|
+
...new Set([
|
|
24
|
+
DEFAULT_TYPE,
|
|
25
|
+
"mobile",
|
|
26
|
+
"tablet",
|
|
27
|
+
...Object.keys(variations).filter((name) => /^[\w-]+$/.test(name)),
|
|
28
|
+
]),
|
|
29
|
+
];
|
|
30
|
+
return names.map((name) => ({
|
|
31
|
+
name: name === DEFAULT_TYPE ? "desktop" : name,
|
|
32
|
+
value: name,
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
2
35
|
export class DiffServiceFactory {
|
|
3
36
|
context;
|
|
4
37
|
service = undefined;
|
|
5
38
|
constructor(context) {
|
|
6
39
|
this.context = context;
|
|
7
40
|
}
|
|
8
|
-
|
|
41
|
+
async buildService() {
|
|
9
42
|
if (!(this.service instanceof DiffService)) {
|
|
10
|
-
|
|
11
|
-
this.service = new DiffService(cliService, this.context.executablePath, this.context.executableTemplate, this.context.opensDiffTool ?? true);
|
|
43
|
+
this.service = await this.build();
|
|
12
44
|
}
|
|
13
45
|
return this.service;
|
|
14
46
|
}
|
|
47
|
+
async build() {
|
|
48
|
+
const { environment } = this.context;
|
|
49
|
+
const chosenParameters = await this.withChosenParameters();
|
|
50
|
+
const json = this.context.output === "json";
|
|
51
|
+
const log = json ? stderrLog(environment.cli) : environment.cli;
|
|
52
|
+
const files = this.context.customerPath
|
|
53
|
+
? await this.getIntegrationFiles()
|
|
54
|
+
: undefined;
|
|
55
|
+
const customer = files?.getCustomerConfig().config;
|
|
56
|
+
// JSON owns stdout, so the proxy line stays out of a machine-readable run.
|
|
57
|
+
if (customer) {
|
|
58
|
+
const { pageUrl, against } = this.context;
|
|
59
|
+
for (const url of [pageUrl, against].filter(Boolean)) {
|
|
60
|
+
assertCustomerOrigin(url, customer.origins, this.context.customerPath);
|
|
61
|
+
}
|
|
62
|
+
applyOriginProxy(customer.chromeFlags, json ? undefined : environment.cli);
|
|
63
|
+
}
|
|
64
|
+
const config = await this.loadRuntimeConfig(log, customer?.app);
|
|
65
|
+
if (!config) {
|
|
66
|
+
throw new ApplicationError("no runtime config to build the requests from");
|
|
67
|
+
}
|
|
68
|
+
const options = await this.withChosenVariations(chosenParameters, config.variations);
|
|
69
|
+
// Installed last, after everything that can fail: the service closes it.
|
|
70
|
+
const browserFetch = this.context.browserFetch
|
|
71
|
+
? installBrowserOriginFetch({ environment, logger: log, mode: "always" })
|
|
72
|
+
: undefined;
|
|
73
|
+
if (browserFetch) {
|
|
74
|
+
log.writeWarning("Fetching every page through a headless Chrome.");
|
|
75
|
+
}
|
|
76
|
+
return new DiffService({
|
|
77
|
+
options,
|
|
78
|
+
log,
|
|
79
|
+
browserFetch,
|
|
80
|
+
engine: createDiffEngine(environment, this.context.output),
|
|
81
|
+
pages: new PageSource({
|
|
82
|
+
fetcher: new OriginFetcher({
|
|
83
|
+
cli: log,
|
|
84
|
+
config,
|
|
85
|
+
host: this.context.host,
|
|
86
|
+
strict: true,
|
|
87
|
+
}),
|
|
88
|
+
documentHandler: this.context.raw || !files
|
|
89
|
+
? undefined
|
|
90
|
+
: await this.buildDocumentHandler(files),
|
|
91
|
+
ignore: this.context.ignore.map((pattern) => new RegExp(pattern, "g")),
|
|
92
|
+
}),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The options, with the parameters an empty `--param` asked for added to
|
|
97
|
+
* the ones removed. Asked first, before anything is loaded or fetched.
|
|
98
|
+
*/
|
|
99
|
+
async withChosenParameters() {
|
|
100
|
+
if (!this.context.chooseParameters)
|
|
101
|
+
return this.context;
|
|
102
|
+
const { environment, pageUrl, parameters = [] } = this.context;
|
|
103
|
+
const names = [...new Set(new URL(pageUrl).searchParams.keys())];
|
|
104
|
+
const chosen = await environment.cli.multiSelect("Which parameters should be removed?", names.map((name) => ({ name, value: name })));
|
|
105
|
+
if (chosen.length === 0 && parameters.length === 0) {
|
|
106
|
+
throw new ApplicationError("No parameter chosen, so nothing to check.");
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
...this.context,
|
|
110
|
+
parameters: [...new Set([...parameters, ...chosen])],
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The options, with the variations an empty `--variations` or
|
|
115
|
+
* `--variation` asked for.
|
|
116
|
+
*/
|
|
117
|
+
async withChosenVariations(options, variations) {
|
|
118
|
+
if (options.chooseVariation) {
|
|
119
|
+
return { ...options, variation: await this.chooseVariation(variations) };
|
|
120
|
+
}
|
|
121
|
+
if (!options.chooseVariations)
|
|
122
|
+
return options;
|
|
123
|
+
const chosen = await this.context.environment.cli.multiSelect("Which variations should be compared? One is compared against desktop", variationChoices(variations), (picked) => (picked.length === 1 && picked[0] !== DEFAULT_TYPE) ||
|
|
124
|
+
picked.length === 2 ||
|
|
125
|
+
"Choose one variation to compare against desktop, or two to compare with each other.");
|
|
126
|
+
// A quiet CLI (--output json) does not ask, and answers with no choice.
|
|
127
|
+
if (chosen.length === 0) {
|
|
128
|
+
throw new ApplicationError("No variation chosen, so nothing to compare.", ["Name them: --variations mobile, or --variations tablet,mobile"]);
|
|
129
|
+
}
|
|
130
|
+
return { ...options, variations: variationPair(chosen) };
|
|
131
|
+
}
|
|
132
|
+
/** The one variation an empty `--variation` asks for. */
|
|
133
|
+
async chooseVariation(variations) {
|
|
134
|
+
// JSON owns stdout, where the prompt would land.
|
|
135
|
+
if (this.context.output === "json") {
|
|
136
|
+
throw new ApplicationError("An empty --variation asks which variation to take, and --output json cannot ask.", ["Name it: --variation mobile"]);
|
|
137
|
+
}
|
|
138
|
+
return this.context.environment.cli.select("Which variation should the pages be requested in?", variationChoices(variations), DEFAULT_TYPE);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The runtime config: a local file when one is named, else the app's. Without
|
|
142
|
+
* a customer there is no app, and the requests carry Speed Kit's device
|
|
143
|
+
* defaults only.
|
|
144
|
+
*/
|
|
145
|
+
async loadRuntimeConfig(log, app) {
|
|
146
|
+
if (!app && !this.context.variationsFile) {
|
|
147
|
+
log.writeWarning("no customer: the requests carry Speed Kit's device defaults only, no variations of an app");
|
|
148
|
+
return { variations: {}, authentications: [] };
|
|
149
|
+
}
|
|
150
|
+
return new RuntimeConfigSource({
|
|
151
|
+
cli: log,
|
|
152
|
+
configApi: app
|
|
153
|
+
? new ConfigApiServiceFactory(new ConfigApiContext(app)).getService()
|
|
154
|
+
: undefined,
|
|
155
|
+
fileFlag: "--variationsFile",
|
|
156
|
+
}).load(this.context.variationsFile);
|
|
157
|
+
}
|
|
158
|
+
/** The customer's files, with the released document handler unless it brings its own. */
|
|
159
|
+
async getIntegrationFiles() {
|
|
160
|
+
return new IntegrationApiFactory(new IntegrationApiServiceBuildContext({
|
|
161
|
+
environment: this.context.environment,
|
|
162
|
+
basePath: this.context.customerPath,
|
|
163
|
+
configName: this.context.configName,
|
|
164
|
+
whitelist: [],
|
|
165
|
+
}))
|
|
166
|
+
.buildService()
|
|
167
|
+
.run(this.context.raw ? [] : documentHandlerRuntimeFiles());
|
|
168
|
+
}
|
|
169
|
+
async buildDocumentHandler(files) {
|
|
170
|
+
return new DocumentHandlerRuntimeServiceFactory(new DocumentHandlerRuntimeServiceBuildContext({
|
|
171
|
+
environment: this.context.environment,
|
|
172
|
+
customerPath: this.context.customerPath,
|
|
173
|
+
configName: this.context.configName,
|
|
174
|
+
verboseLevel: false,
|
|
175
|
+
}), files).buildDocumentHandlerServer();
|
|
176
|
+
}
|
|
15
177
|
}
|
|
@@ -1,43 +1,103 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DiffEngine } from "./diff-engine.js";
|
|
2
|
+
import { DiffLog } from "./diff-log.js";
|
|
3
|
+
import { ComparisonOutcome } from "./diff-model.js";
|
|
4
|
+
import { DiffOptions } from "./diff-service-build-context.js";
|
|
5
|
+
import { BrowserOriginFetchHandle } from "../browser-fetch/index.js";
|
|
6
|
+
import { PageSource } from "./page-source.js";
|
|
7
|
+
export interface DiffServiceDeps {
|
|
8
|
+
readonly options: DiffOptions;
|
|
9
|
+
readonly log: DiffLog;
|
|
10
|
+
readonly engine: DiffEngine;
|
|
11
|
+
readonly pages: PageSource;
|
|
12
|
+
/** The headless Chrome pages are fetched through; closed when the run ends. */
|
|
13
|
+
readonly browserFetch?: BrowserOriginFetchHandle;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `sk diff`: compares one page, as Speed Kit's server would request and the
|
|
17
|
+
* customer's documentHandler would render it, along two axes, or against
|
|
18
|
+
* another page.
|
|
19
|
+
*
|
|
20
|
+
* - **Parameters:** the page against itself with its query parameters
|
|
21
|
+
* removed. A parameter that changes nothing can be dropped from the cache
|
|
22
|
+
* key; one that changes the page must stay. When removing all of them makes
|
|
23
|
+
* a difference, each is checked on its own, so the report names the ones
|
|
24
|
+
* that matter.
|
|
25
|
+
* - **Variations:** the page in one variation against another
|
|
26
|
+
* variation, which shows whether the origin serves a device or a custom
|
|
27
|
+
* variation different markup.
|
|
28
|
+
*
|
|
29
|
+
* With both, the parameter check runs once per variation, each against that
|
|
30
|
+
* variation's own page. Without variations, the parameter check runs in the
|
|
31
|
+
* one `variation` names, desktop by default.
|
|
32
|
+
*
|
|
33
|
+
* - **Against:** the page against another page in one variation, such as
|
|
34
|
+
* `?color=red` against `?color=blue`. With and without a parameter cannot
|
|
35
|
+
* tell a filter apart from a shop that answers a missing or unknown value
|
|
36
|
+
* with the unfiltered page; two values can.
|
|
37
|
+
*
|
|
38
|
+
* Parameters selected by name are checked once, all removed together while
|
|
39
|
+
* the others stay in the url, without the check of removing all of them.
|
|
40
|
+
*
|
|
41
|
+
* With `baseline`, every side is fetched twice, and what differs between the
|
|
42
|
+
* two is noise no comparison counts. Each side is fetched once per run, so a
|
|
43
|
+
* page that takes part in several comparisons costs its requests once.
|
|
44
|
+
*
|
|
45
|
+
* A side that fails ends its comparison, not the run. When the
|
|
46
|
+
* documentHandler aborts a side, Speed Kit never caches it, so that
|
|
47
|
+
* comparison is `uncacheable`; any other failure leaves it `failed`.
|
|
48
|
+
*/
|
|
2
49
|
export declare class DiffService {
|
|
3
|
-
private
|
|
4
|
-
private
|
|
5
|
-
private
|
|
6
|
-
|
|
7
|
-
private
|
|
8
|
-
constructor(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
50
|
+
private readonly deps;
|
|
51
|
+
private readonly outcomes;
|
|
52
|
+
private readonly sides;
|
|
53
|
+
/** The hints written, so a failure seen in several comparisons writes them once. */
|
|
54
|
+
private readonly hinted;
|
|
55
|
+
constructor(deps: DiffServiceDeps);
|
|
56
|
+
/**
|
|
57
|
+
* Runs every comparison. Resolves to the worst outcome among them: a
|
|
58
|
+
* comparison that failed before one that differed, before one that is not
|
|
59
|
+
* cacheable.
|
|
60
|
+
*/
|
|
61
|
+
run(): Promise<ComparisonOutcome>;
|
|
62
|
+
private check;
|
|
63
|
+
/** The page against another page, both in one variation. */
|
|
64
|
+
private checkAgainst;
|
|
65
|
+
private checkVariations;
|
|
66
|
+
/**
|
|
67
|
+
* Without variations the parameters are all there is to compare. A url
|
|
68
|
+
* without any is a mistake, not a page without a diff, so it does not end
|
|
69
|
+
* as one.
|
|
70
|
+
*/
|
|
71
|
+
private assertParameters;
|
|
72
|
+
private checkParameters;
|
|
14
73
|
/**
|
|
15
|
-
*
|
|
74
|
+
* The page against itself without each group of parameters. With
|
|
75
|
+
* `stripped`, each comparison also says whether its difference is the one
|
|
76
|
+
* removing every parameter makes.
|
|
16
77
|
*/
|
|
17
|
-
|
|
78
|
+
private checkEachParameter;
|
|
18
79
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
80
|
+
* Compares two sides and reports the verdict. With `stripped`, the
|
|
81
|
+
* verdict also says whether the difference is the one removing every
|
|
82
|
+
* parameter makes: when it is not, the parameter matters together with
|
|
83
|
+
* the others too. The right side carries the answer as
|
|
84
|
+
* `sameAsWithoutAnyParam`, for a sink that reports it.
|
|
24
85
|
*/
|
|
25
|
-
private
|
|
26
|
-
writeContentToTemporalFile(temporaryFileName: string, content: string): Promise<string>;
|
|
86
|
+
private compare;
|
|
27
87
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
88
|
+
* Reports a comparison a side of failed. It is `uncacheable` when every
|
|
89
|
+
* failed side is a documentHandler abort: Speed Kit never caches such a
|
|
90
|
+
* page, which is a verdict in itself. Any other failure leaves the
|
|
91
|
+
* comparison `failed`.
|
|
32
92
|
*/
|
|
33
|
-
|
|
93
|
+
private reportFailure;
|
|
94
|
+
private settle;
|
|
95
|
+
private diffVerdict;
|
|
34
96
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @param firstPath
|
|
39
|
-
* @param secondPath
|
|
40
|
-
* @param skipDiffExecution
|
|
97
|
+
* The side of a url in a variation, fetched once per run. A side Speed
|
|
98
|
+
* Kit's server would fail on resolves to that failure; any other error
|
|
99
|
+
* ends the run.
|
|
41
100
|
*/
|
|
42
|
-
|
|
101
|
+
private side;
|
|
102
|
+
private announce;
|
|
43
103
|
}
|