@speedkit/cli 4.38.0 → 4.38.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 +7 -0
- package/dist/services/onboarding/onboarding-service-factory.js +3 -0
- package/dist/services/onboarding/spec/virtual-orestes-app/crawler.spec.js +22 -2
- package/dist/services/onboarding/virtual-orestes-app/crawler.d.ts +4 -2
- package/dist/services/onboarding/virtual-orestes-app/crawler.js +13 -8
- package/dist/services/origin-request/spec/asset-variations.spec.js +10 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [4.38.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.38.0...v4.38.1) (2026-10-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **onboarding:** adapt errors regarding missing serverConfig ([aa0694b](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/aa0694b852030673bdbe32e92900004d730e4e02))
|
|
7
|
+
|
|
1
8
|
# [4.38.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.37.0...v4.38.0) (2026-10-02)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -267,6 +267,9 @@ export class OnboardingServiceFactory {
|
|
|
267
267
|
const serverConfigResult = await safe(configApi.getServerConfig());
|
|
268
268
|
if (serverConfigResult.success !== true) {
|
|
269
269
|
cli.failAction("ONBOARDING:FETCH:RUNTIME_CONFIG");
|
|
270
|
+
// Everything the runtime config alone carries is gone for this session, including any
|
|
271
|
+
// override of a device variation. Those still resolve, from their built-in defaults only.
|
|
272
|
+
cli.writeWarning("without the runtime config, origin fetches carry no basic auth, no custom variation and no configured override of default, mobile or tablet — those fall back to the built-in defaults. Are you logged in?");
|
|
270
273
|
return;
|
|
271
274
|
}
|
|
272
275
|
cli.successAction("ONBOARDING:FETCH:RUNTIME_CONFIG");
|
|
@@ -45,11 +45,31 @@ describe("Crawler.fetchRemote", () => {
|
|
|
45
45
|
expect(result).to.not.equal(undefined);
|
|
46
46
|
expect(await result.response.text()).to.equal("origin");
|
|
47
47
|
});
|
|
48
|
-
it("
|
|
48
|
+
it("stays quiet about a device variation without a runtime config", async () => {
|
|
49
49
|
const { cli, warnings } = stubCli();
|
|
50
|
+
// default, mobile and tablet fall back to their built-in defaults, so the fetch still
|
|
51
|
+
// resolves. Any override the runtime config would carry for them is lost, but the failed
|
|
52
|
+
// config load reports that itself.
|
|
50
53
|
const result = await new Crawler(cli, undefined).fetchRemote(url, "DEFAULT");
|
|
51
54
|
expect(await result.response.text()).to.equal("origin");
|
|
52
|
-
expect(warnings
|
|
55
|
+
expect(warnings).to.deep.equal([]);
|
|
56
|
+
});
|
|
57
|
+
it("names the defined variations when a custom one is missing", async () => {
|
|
58
|
+
const { cli, warnings } = stubCli();
|
|
59
|
+
const serverConfig = {
|
|
60
|
+
speedKit: { variations: { "*": { headers: {} }, "store-de": {} } },
|
|
61
|
+
};
|
|
62
|
+
const crawler = new Crawler(cli, serverConfig);
|
|
63
|
+
await crawler.fetchRemote(url, "store-ch");
|
|
64
|
+
await crawler.fetchRemote(url, "store-ch");
|
|
65
|
+
expect(warnings).to.have.lengthOf(1);
|
|
66
|
+
expect(warnings[0]).to.contain("variation store-ch is not defined");
|
|
67
|
+
expect(warnings[0]).to.contain("defined are: *, store-de");
|
|
68
|
+
});
|
|
69
|
+
it("says the runtime config defines no variations at all", async () => {
|
|
70
|
+
const { cli, warnings } = stubCli();
|
|
71
|
+
await new Crawler(cli, undefined).fetchRemote(url, "store-ch");
|
|
72
|
+
expect(warnings.join(" ")).to.contain("it defines no variations at all");
|
|
53
73
|
});
|
|
54
74
|
describe("a runtime config that sets Accept-Language to null", () => {
|
|
55
75
|
const withVariations = (variations) => ({ speedKit: { variations } });
|
|
@@ -21,8 +21,10 @@ export declare class Crawler {
|
|
|
21
21
|
* templates with their `${group}` substitution, and the query params.
|
|
22
22
|
*
|
|
23
23
|
* Two things stay local: origin basic auth, which no variation carries, and tolerance for a
|
|
24
|
-
* variation the config does not define — the server rejects that request, but failing a
|
|
25
|
-
* onboarding session over it would be unhelpful, so it falls back to the base headers and
|
|
24
|
+
* custom variation the config does not define — the server rejects that request, but failing a
|
|
25
|
+
* whole onboarding session over it would be unhelpful, so it falls back to the base headers and
|
|
26
|
+
* warns once. A missing runtime config is not reported here; the fetch that failed to load it
|
|
27
|
+
* says what it costs.
|
|
26
28
|
*/
|
|
27
29
|
private prepareOriginRequest;
|
|
28
30
|
private prepareAuthRequest;
|
|
@@ -42,24 +42,29 @@ export class Crawler {
|
|
|
42
42
|
* templates with their `${group}` substitution, and the query params.
|
|
43
43
|
*
|
|
44
44
|
* Two things stay local: origin basic auth, which no variation carries, and tolerance for a
|
|
45
|
-
* variation the config does not define — the server rejects that request, but failing a
|
|
46
|
-
* onboarding session over it would be unhelpful, so it falls back to the base headers and
|
|
45
|
+
* custom variation the config does not define — the server rejects that request, but failing a
|
|
46
|
+
* whole onboarding session over it would be unhelpful, so it falls back to the base headers and
|
|
47
|
+
* warns once. A missing runtime config is not reported here; the fetch that failed to load it
|
|
48
|
+
* says what it costs.
|
|
47
49
|
*/
|
|
48
50
|
prepareOriginRequest(originUrl, variationParameter) {
|
|
49
51
|
const variations = this.speedKitServerConfig?.speedKit?.variations ?? {};
|
|
50
|
-
// An empty map means the runtime config never loaded, so no fetch can carry variation headers.
|
|
51
|
-
// Say that once, rather than blaming each variation for being undefined.
|
|
52
|
-
if (!Object.keys(variations).length) {
|
|
53
|
-
this.warnOnce("no-runtime-config", "no variations available from the runtime config, so origin fetches carry the base headers only — the cached document may differ from production. Are you logged in?");
|
|
54
|
-
}
|
|
55
52
|
let resolved;
|
|
56
53
|
try {
|
|
57
54
|
resolved = resolveRequest(variations, originUrl, variationParameter);
|
|
58
55
|
}
|
|
59
56
|
catch (error) {
|
|
57
|
+
// Only a custom variation reaches this branch: a device variation (default, mobile, tablet)
|
|
58
|
+
// never throws. It starts from its built-in default, and an entry for it in the runtime
|
|
59
|
+
// config is applied on top, so a configured user agent or header still wins.
|
|
60
60
|
if (!(error instanceof UndefinedVariationError))
|
|
61
61
|
throw error;
|
|
62
|
-
|
|
62
|
+
const defined = Object.keys(variations);
|
|
63
|
+
this.warnOnce(`undefined-variation:${variationParameter}`, `variation ${variationParameter} is not defined in the runtime config — ` +
|
|
64
|
+
(defined.length
|
|
65
|
+
? `defined are: ${defined.join(", ")}. `
|
|
66
|
+
: "it defines no variations at all. ") +
|
|
67
|
+
"Falling back to the base headers.");
|
|
63
68
|
resolved = resolveRequest({}, originUrl);
|
|
64
69
|
}
|
|
65
70
|
const init = { headers: { ...resolved.headers } };
|
|
@@ -23,6 +23,16 @@ describe("asset variations", () => {
|
|
|
23
23
|
expect(resolutionPath).to.equal("template");
|
|
24
24
|
expect(appliedKeys).to.deep.equal(["*", "desktop-fmarkt-variant"]);
|
|
25
25
|
});
|
|
26
|
+
it("lets a configured device variation override its built-in default", () => {
|
|
27
|
+
const { appliedKeys, headers } = resolveRequest({
|
|
28
|
+
mobile: {
|
|
29
|
+
headers: { "user-agent": "custom-mobile-agent", "x-device": "m" },
|
|
30
|
+
},
|
|
31
|
+
}, "https://www.example.com/plp", "mobile");
|
|
32
|
+
expect(appliedKeys).to.deep.equal(["device-default:mobile", "mobile"]);
|
|
33
|
+
expect(headers["user-agent"]).to.equal("custom-mobile-agent");
|
|
34
|
+
expect(headers["x-device"]).to.equal("m");
|
|
35
|
+
});
|
|
26
36
|
it("matches a template only against the whole variation, and rejects what matches nothing", () => {
|
|
27
37
|
// The desktop template cannot match a mobile variation, and the server does not fall back to
|
|
28
38
|
// the "mobile" device default by substring — that is the pre-renderer's rule, not the server's.
|
package/oclif.manifest.json
CHANGED