@speedkit/cli 4.45.0 → 4.45.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 +8 -0
- package/dist/commands/origin-request.js +3 -1
- package/dist/services/diff/side-failure.js +17 -1
- package/dist/services/diff/spec/diff-service.spec.js +16 -0
- package/dist/services/onboarding/onboarding-model.d.ts +0 -6
- package/dist/services/onboarding/onboarding-model.js +0 -6
- package/dist/services/origin-request/origin-request-service.d.ts +2 -1
- package/dist/services/origin-request/origin-request-service.js +4 -2
- package/dist/services/origin-request/spec/origin-request-service.spec.d.ts +1 -0
- package/dist/services/origin-request/spec/origin-request-service.spec.js +9 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [4.45.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.45.0...v4.45.1) (2026-10-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **diff:** an unreachable local pre-renderer fails the diff ([9b92707](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/9b927072fcd751f0fffea3f12c53bd5d9d63573d))
|
|
7
|
+
* **origin-request:** exit 2 when the runtime config cannot be used ([613b6e0](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/613b6e035b866ffc3d9e1c39683d6cb02cb42fd5))
|
|
8
|
+
|
|
1
9
|
# [4.45.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.44.1...v4.45.0) (2026-10-15)
|
|
2
10
|
|
|
3
11
|
|
|
@@ -13,6 +13,8 @@ export default class OriginRequest extends SkCommand {
|
|
|
13
13
|
];
|
|
14
14
|
async run() {
|
|
15
15
|
const service = await new OriginRequestServiceFactory(this.context).buildService();
|
|
16
|
-
|
|
16
|
+
// Exit 2 like `sk diff` when nothing could be requested, so a script does not read a success.
|
|
17
|
+
if (!(await service.run()))
|
|
18
|
+
this.exit(2);
|
|
17
19
|
}
|
|
18
20
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { ABORT_ERROR_CODE, DOCUMENT_HANDLER_ERROR_CODE, isDocumentHandlerAbort, } from "../document-handler-runtime/document-handler-abort.js";
|
|
1
|
+
import { ABORT_ERROR_CODE, DOCUMENT_HANDLER_ERROR_CODE, isDocumentHandlerAbort, isLocalPrerendererUnreachable, LOCAL_PRERENDERER_PORT, } from "../document-handler-runtime/document-handler-abort.js";
|
|
2
2
|
import ApplicationError from "../error-handling/error/application-error.js";
|
|
3
3
|
import { DocumentHandlerTransformError } from "../onboarding/error/document-handler-transform-error.js";
|
|
4
4
|
import { VmEmptyResponseError } from "../onboarding/error/vm-empty-response-error.js";
|
|
5
5
|
import { ORIGIN_ERROR_CODE, originErrorCauseName, originErrorCode, } from "../origin-request/index.js";
|
|
6
|
+
/** The cause of an SSR fetch that found no local pre-renderer: a setup gap, not a verdict. */
|
|
7
|
+
const LOCAL_PRERENDERER_UNREACHABLE = "LocalPrerendererUnreachable";
|
|
6
8
|
/** How a failure reads in a log line: its cause name and Speed Kit error code. */
|
|
7
9
|
function causeLine(failure) {
|
|
8
10
|
return `${failure.cause} (${failure.code})`;
|
|
@@ -14,6 +16,11 @@ function hints(failure) {
|
|
|
14
16
|
"Speed Kit never caches this page: the documentHandler aborts it, and the service worker falls back to origin.",
|
|
15
17
|
];
|
|
16
18
|
}
|
|
19
|
+
if (failure.cause === LOCAL_PRERENDERER_UNREACHABLE) {
|
|
20
|
+
return [
|
|
21
|
+
"Start the pre-renderer in puppeteer-lambda (`npm run run:dev`), then diff again.",
|
|
22
|
+
];
|
|
23
|
+
}
|
|
17
24
|
if (failure.kind === "documentHandlerError") {
|
|
18
25
|
return [
|
|
19
26
|
"Check config_documentHandler.es6 | custom_documentHandler.js: the documentHandler threw.",
|
|
@@ -84,6 +91,15 @@ export function documentHandlerFailure(error) {
|
|
|
84
91
|
!(error instanceof VmEmptyResponseError)) {
|
|
85
92
|
return undefined;
|
|
86
93
|
}
|
|
94
|
+
// The documentHandler wraps the refused SSR fetch as an abort, but Speed Kit's server has a renderer.
|
|
95
|
+
if (isLocalPrerendererUnreachable(error)) {
|
|
96
|
+
return {
|
|
97
|
+
kind: "documentHandlerError",
|
|
98
|
+
code: DOCUMENT_HANDLER_ERROR_CODE,
|
|
99
|
+
cause: LOCAL_PRERENDERER_UNREACHABLE,
|
|
100
|
+
reason: `SSR is configured, but no pre-renderer is listening on localhost:${LOCAL_PRERENDERER_PORT}`,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
87
103
|
return isDocumentHandlerAbort(error)
|
|
88
104
|
? {
|
|
89
105
|
kind: "documentHandlerAbort",
|
|
@@ -329,6 +329,22 @@ describe("DiffService failed sides", () => {
|
|
|
329
329
|
});
|
|
330
330
|
expect(log.lines.join("\n")).to.contain("ServerDocumentHandlerAbort (303): old-engine PLP");
|
|
331
331
|
});
|
|
332
|
+
it("fails, not ends as not cacheable, when no local pre-renderer listens", async () => {
|
|
333
|
+
const refused = new TypeError("fetch failed", {
|
|
334
|
+
cause: { code: "ECONNREFUSED", port: 3001 },
|
|
335
|
+
});
|
|
336
|
+
const { diff, failed, log } = service("https://shop.test/?a=1", {
|
|
337
|
+
"https://shop.test/?a=1": new PageSideFailure({
|
|
338
|
+
url: "https://shop.test/?a=1",
|
|
339
|
+
variation: "default",
|
|
340
|
+
failure: documentHandlerFailure(new DocumentHandlerTransformError(new DocumentHandlerAbort(refused.toString(), { error: refused }))),
|
|
341
|
+
}),
|
|
342
|
+
"https://shop.test/": "<p>none</p>",
|
|
343
|
+
});
|
|
344
|
+
expect(await diff.run()).to.equal("failed");
|
|
345
|
+
expect(failed[0].outcome).to.equal("failed");
|
|
346
|
+
expect(log.lines.join("\n")).to.contain("Start the pre-renderer");
|
|
347
|
+
});
|
|
332
348
|
it("ranks a diff above a page that is not cacheable", async () => {
|
|
333
349
|
const { diff, failed } = service("https://shop.test/?a=1&b=2", {
|
|
334
350
|
"https://shop.test/?a=1&b=2": "<p>a b</p>",
|
|
@@ -184,11 +184,5 @@ export type DevelopmentToolsMessage = {
|
|
|
184
184
|
id: "localCacheError";
|
|
185
185
|
data: LocalCacheError[];
|
|
186
186
|
};
|
|
187
|
-
export declare const USER_AGENT: {
|
|
188
|
-
DESKTOP: string;
|
|
189
|
-
MOBILE: string;
|
|
190
|
-
TABLET: string;
|
|
191
|
-
TV: string;
|
|
192
|
-
};
|
|
193
187
|
export declare const SpeedKitInstallRegex: RegExp;
|
|
194
188
|
export declare const META_CONTENT_TYPE_REGEX: RegExp;
|
|
@@ -208,11 +208,5 @@ export class BrowserContext {
|
|
|
208
208
|
export const DEFAULT_DF_PATH = "https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js";
|
|
209
209
|
export const DEFAULT_SNIPPET_PATH = "https://www.baqend.com/speed-kit/latest/snippet.js";
|
|
210
210
|
export const DEFAULT_SW_PATH = "https://www.baqend.com/speed-kit/latest/sw.js";
|
|
211
|
-
export const USER_AGENT = {
|
|
212
|
-
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)",
|
|
213
|
-
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)",
|
|
214
|
-
TABLET: "Mozilla/5.0 (iPad; CPU 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)",
|
|
215
|
-
TV: "Mozilla/5.0 (Linux; NetCast; U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36 SmartTV/10.0 Colt/2.0 (compatible; SpeedKit/1.0)",
|
|
216
|
-
};
|
|
217
211
|
export const SpeedKitInstallRegex = /<script[^>]*src[^>]*app\.baqend\.com\/v1\/speedkit\/install.js[^>]*>(?:(?!<\/script>).)*<\/script>/s;
|
|
218
212
|
export const META_CONTENT_TYPE_REGEX = /<meta[^"]*http-equiv="content-type"[^"]*content="text\/html;[^"]*charset=([^\s"(),./:;<=>?@[\]]*)"/is;
|
|
@@ -24,6 +24,7 @@ export declare class OriginRequestService {
|
|
|
24
24
|
constructor(context: OriginRequestOptions, cli: CliServiceInterface,
|
|
25
25
|
/** Absent when the runtime config could not be used; the reason is reported. */
|
|
26
26
|
fetcher: OriginFetcher | undefined);
|
|
27
|
-
|
|
27
|
+
/** False when the request was not sent, because the runtime config could not be used. */
|
|
28
|
+
run(): Promise<boolean>;
|
|
28
29
|
private report;
|
|
29
30
|
}
|
|
@@ -36,11 +36,12 @@ export class OriginRequestService {
|
|
|
36
36
|
this.cli = cli;
|
|
37
37
|
this.fetcher = fetcher;
|
|
38
38
|
}
|
|
39
|
+
/** False when the request was not sent, because the runtime config could not be used. */
|
|
39
40
|
async run() {
|
|
40
41
|
// Without a runtime config every request would resolve to the bare defaults, so the report
|
|
41
42
|
// would describe a request the server never sends. Stop instead of simulating something wrong.
|
|
42
43
|
if (!this.fetcher)
|
|
43
|
-
return;
|
|
44
|
+
return false;
|
|
44
45
|
const variation = this.context.variation ?? DEFAULT_TYPE;
|
|
45
46
|
const { url, init, resolved } = this.fetcher.prepare(this.context.pageUrl, this.context.variation);
|
|
46
47
|
const headers = printable(init.headers);
|
|
@@ -61,9 +62,10 @@ export class OriginRequestService {
|
|
|
61
62
|
setCookie: setCookies,
|
|
62
63
|
bodyLength: body.length,
|
|
63
64
|
}, null, 2));
|
|
64
|
-
return;
|
|
65
|
+
return true;
|
|
65
66
|
}
|
|
66
67
|
this.report(variation, resolved, headers, response, setCookies, body);
|
|
68
|
+
return true;
|
|
67
69
|
}
|
|
68
70
|
report(variation, resolved, headers, response, setCookies, body) {
|
|
69
71
|
this.cli.write(`variation ${variation}`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
|
+
import { OriginRequestService } from "../origin-request-service.js";
|
|
4
|
+
describe("OriginRequestService", () => {
|
|
5
|
+
it("reports that it sent nothing when the runtime config was not usable", async () => {
|
|
6
|
+
const service = new OriginRequestService({ pageUrl: "https://shop.test/" }, {}, undefined);
|
|
7
|
+
expect(await service.run()).to.equal(false);
|
|
8
|
+
});
|
|
9
|
+
});
|
package/oclif.manifest.json
CHANGED