@speedkit/cli 4.44.0-beta.4 → 4.44.0-beta.5
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 +14 -0
- package/dist/services/bundler/packjockel-service.d.ts +24 -0
- package/dist/services/bundler/packjockel-service.js +26 -0
- package/dist/services/bundler/spec/packjockel-service.spec.js +25 -0
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.d.ts +2 -0
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +19 -15
- package/dist/services/onboarding/file-events/file-watcher.d.ts +3 -1
- package/dist/services/onboarding/file-events/file-watcher.js +9 -2
- package/dist/services/onboarding/spec/file-events/file-watcher.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/file-events/file-watcher.spec.js +67 -0
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [4.44.0-beta.5](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.44.0-beta.4...v4.44.0-beta.5) (2026-10-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **onboarding:** rebuild the document handler when config_SpeedKit changes ([406b07a](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/406b07af2fb050dfb38b7fdfbcfc7b74ddfe6dd7))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **bundler:** bundle the install script with packjockel install-script ([a4d22d5](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/a4d22d525a148fcc1b2e24932af6571865f49dc7))
|
|
12
|
+
* **bundler:** run packjockel 3.2.0 for the install-script subcommand ([ff90fcb](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/ff90fcb37627dc2115293e5e96aea4403a12e128))
|
|
13
|
+
* **onboarding:** pass the feature flags of the customer to the packjockel install script ([976bcf2](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/976bcf2bd89b51b44ee8cfe73e4426af5aad60bf))
|
|
14
|
+
|
|
1
15
|
# [4.44.0-beta.4](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.44.0-beta.3...v4.44.0-beta.4) (2026-10-14)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -21,6 +21,23 @@ export interface PackjockelBundleRequest {
|
|
|
21
21
|
target?: "es5" | "es6";
|
|
22
22
|
minify?: boolean;
|
|
23
23
|
}
|
|
24
|
+
export interface PackjockelInstallScriptRequest {
|
|
25
|
+
/** The config plugins, such as the `rum.js` load handler. */
|
|
26
|
+
plugins: string;
|
|
27
|
+
/** The Speed Kit config, which writes `SpeedKit.config`. */
|
|
28
|
+
config: string;
|
|
29
|
+
loader: string;
|
|
30
|
+
/** Set as `SpeedKit.config.installationId`. */
|
|
31
|
+
installationId: string;
|
|
32
|
+
/**
|
|
33
|
+
* The feature flags of the app. packjockel reads the flags it knows, such as `executeInIframe`, and
|
|
34
|
+
* ignores the others.
|
|
35
|
+
*/
|
|
36
|
+
features?: Record<string, boolean>;
|
|
37
|
+
versions?: AssetVersions;
|
|
38
|
+
define?: Record<string, string>;
|
|
39
|
+
minify?: boolean;
|
|
40
|
+
}
|
|
24
41
|
export interface PackjockelDocumentHandlerRequest {
|
|
25
42
|
/** The document handler library; without it packjockel bundles the published one of `documentHandlerVersion`. */
|
|
26
43
|
documentHandler?: string;
|
|
@@ -52,6 +69,13 @@ export declare class PackjockelService {
|
|
|
52
69
|
* @returns the bundled code
|
|
53
70
|
*/
|
|
54
71
|
bundle(request: PackjockelBundleRequest): Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Bundles the Speed Kit install script: the `SpeedKit` global, the plugins, the config, the
|
|
74
|
+
* installation (app, installation id) and the loader, in this order.
|
|
75
|
+
*
|
|
76
|
+
* @returns the install script
|
|
77
|
+
*/
|
|
78
|
+
bundleInstallScript(request: PackjockelInstallScriptRequest): Promise<string>;
|
|
55
79
|
/**
|
|
56
80
|
* Bundles a document handler with its config, the embedded Speed Kit config and the default `post`.
|
|
57
81
|
*
|
|
@@ -50,6 +50,32 @@ export class PackjockelService {
|
|
|
50
50
|
return args;
|
|
51
51
|
}, request.versions);
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Bundles the Speed Kit install script: the `SpeedKit` global, the plugins, the config, the
|
|
55
|
+
* installation (app, installation id) and the loader, in this order.
|
|
56
|
+
*
|
|
57
|
+
* @returns the install script
|
|
58
|
+
*/
|
|
59
|
+
async bundleInstallScript(request) {
|
|
60
|
+
return this.run(async (directory) => {
|
|
61
|
+
const args = [
|
|
62
|
+
"bundle",
|
|
63
|
+
"install-script",
|
|
64
|
+
await writeInput(directory, "loader.js", request.loader),
|
|
65
|
+
`--plugins=${await writeInput(directory, "plugins.js", request.plugins)}`,
|
|
66
|
+
`--config=${await writeInput(directory, "config.js", request.config)}`,
|
|
67
|
+
`--installation-id=${request.installationId}`,
|
|
68
|
+
];
|
|
69
|
+
if (request.features) {
|
|
70
|
+
args.push(`--features=${await writeInput(directory, "features.json", JSON.stringify(request.features))}`);
|
|
71
|
+
}
|
|
72
|
+
if (request.minify) {
|
|
73
|
+
args.push("--minify");
|
|
74
|
+
}
|
|
75
|
+
args.push(...keyValueFlags("--define", request.define));
|
|
76
|
+
return args;
|
|
77
|
+
}, request.versions);
|
|
78
|
+
}
|
|
53
79
|
/**
|
|
54
80
|
* Bundles a document handler with its config, the embedded Speed Kit config and the default `post`.
|
|
55
81
|
*
|
|
@@ -81,6 +81,31 @@ describe("PackjockelService", () => {
|
|
|
81
81
|
"config.js: SpeedKit.config = {}",
|
|
82
82
|
]);
|
|
83
83
|
});
|
|
84
|
+
it("should bundle the install script with its loader, plugins and config", async () => {
|
|
85
|
+
const bundle = await service.bundleInstallScript({
|
|
86
|
+
plugins: "rum()",
|
|
87
|
+
config: "SpeedKit.config = {}",
|
|
88
|
+
loader: "load()",
|
|
89
|
+
installationId: "onboarding",
|
|
90
|
+
features: { executeInIframe: true },
|
|
91
|
+
versions: { speedKitVersion: "2.22.4" },
|
|
92
|
+
define: { APP: '"shop"' },
|
|
93
|
+
});
|
|
94
|
+
const { args, inputs } = await recorded();
|
|
95
|
+
expect(bundle.trim()).to.equal("bundled");
|
|
96
|
+
expect(args.slice(0, 2)).to.deep.equal(["bundle", "install-script"]);
|
|
97
|
+
expect(args).to.include("--installation-id=onboarding");
|
|
98
|
+
expect(args.some((arg) => arg.startsWith("--target")), "packjockel builds the install script for one browser gate").to.equal(false);
|
|
99
|
+
expect(args).to.include('--define=APP="shop"');
|
|
100
|
+
expect(args).to.include("--speed-kit-version=2.22.4");
|
|
101
|
+
expect(args).to.include("--embedded");
|
|
102
|
+
expect(inputs).to.deep.equal([
|
|
103
|
+
"loader.js: load()",
|
|
104
|
+
"plugins.js: rum()",
|
|
105
|
+
"config.js: SpeedKit.config = {}",
|
|
106
|
+
'features.json: {"executeInIframe":true}',
|
|
107
|
+
]);
|
|
108
|
+
});
|
|
84
109
|
it("should bundle a document handler with every input it got", async () => {
|
|
85
110
|
await service.bundleDocumentHandler({
|
|
86
111
|
documentHandler: "var DocumentHandler = 1",
|
|
@@ -9,6 +9,8 @@ export declare class SpeedKitInstallContext {
|
|
|
9
9
|
private skTemplate;
|
|
10
10
|
constructor(customerConfig: CustomerConfig, configName: string, files: FileListInterface, bundler: BundleService, skTemplate: InstallSpeedKitJsTemplate);
|
|
11
11
|
getSpeedKitInstallJs(): Promise<string>;
|
|
12
|
+
/** The boolean feature flags of the customer: packjockel rejects a request with any other value. */
|
|
13
|
+
private getFeatures;
|
|
12
14
|
private prepareConfigLoadHandler;
|
|
13
15
|
/** The Speed Kit config, with `delayRacedOrigin` set to 100 ms for the local documentHandler. */
|
|
14
16
|
private getConfigSpeedKit;
|
|
@@ -32,26 +32,26 @@ export class SpeedKitInstallContext {
|
|
|
32
32
|
.getByName(INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER)
|
|
33
33
|
.getContent(),
|
|
34
34
|
});
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// Like the install script of the server (packjockel!121), without skVersion and installationId:
|
|
39
|
-
// a local run has no installation.
|
|
40
|
-
...(configPlugins && {
|
|
41
|
-
"installation.js": "Object.assign(SpeedKit.config, { app: APP });",
|
|
42
|
-
}),
|
|
43
|
-
"loader.js": this.files
|
|
44
|
-
.getByName(INTEGRATION_FILES.CUSTOM.LOADER)
|
|
45
|
-
.getContent(),
|
|
46
|
-
};
|
|
35
|
+
const loader = this.files
|
|
36
|
+
.getByName(INTEGRATION_FILES.CUSTOM.LOADER)
|
|
37
|
+
.getContent();
|
|
47
38
|
if (configPlugins) {
|
|
48
|
-
return this.bundler.packjockel.
|
|
49
|
-
|
|
39
|
+
return this.bundler.packjockel.bundleInstallScript({
|
|
40
|
+
plugins: this.prepareConfigLoadHandler(),
|
|
41
|
+
config: configJs,
|
|
42
|
+
loader,
|
|
43
|
+
// The local install script belongs to no deployed installation.
|
|
44
|
+
installationId: "onboarding",
|
|
45
|
+
features: this.getFeatures(),
|
|
50
46
|
versions: this.customerConfig,
|
|
51
47
|
define: { APP: JSON.stringify(this.customerConfig.app) },
|
|
52
|
-
platform: "browser",
|
|
53
48
|
});
|
|
54
49
|
}
|
|
50
|
+
const entryPoints = {
|
|
51
|
+
"rum.js": this.prepareConfigLoadHandler(),
|
|
52
|
+
"config.js": configJs,
|
|
53
|
+
"loader.js": loader,
|
|
54
|
+
};
|
|
55
55
|
return this.bundler.bundle({
|
|
56
56
|
basePaths: IMPORT_PATHS,
|
|
57
57
|
entryPoints,
|
|
@@ -63,6 +63,10 @@ export class SpeedKitInstallContext {
|
|
|
63
63
|
},
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
+
/** The boolean feature flags of the customer: packjockel rejects a request with any other value. */
|
|
67
|
+
getFeatures() {
|
|
68
|
+
return Object.fromEntries(Object.entries(this.customerConfig.features ?? {}).filter((entry) => typeof entry[1] === "boolean"));
|
|
69
|
+
}
|
|
66
70
|
prepareConfigLoadHandler() {
|
|
67
71
|
return this.files
|
|
68
72
|
.getByName(INTEGRATION_FILES.CONFIG.LOAD_HANDLER)
|
|
@@ -70,7 +70,9 @@ export declare class FileWatcher {
|
|
|
70
70
|
*/
|
|
71
71
|
private handleDynamicStyles;
|
|
72
72
|
/**
|
|
73
|
-
* fileWatcherCallback that will reinstall the serviceWorker
|
|
73
|
+
* fileWatcherCallback that will reinstall the serviceWorker.
|
|
74
|
+
* With the `enableSpeedKitConfigPlugins` feature, the document handler embeds `config_SpeedKit`,
|
|
75
|
+
* so a change to that file also rebuilds the document handler and drops its cache.
|
|
74
76
|
*
|
|
75
77
|
* @param file
|
|
76
78
|
* @param page
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { safe } from "../../../helpers/safe.js";
|
|
2
|
-
import { FILE_TYPE, } from "../../integration-api/index.js";
|
|
2
|
+
import { FILE_TYPE, usesConfigPlugins, } from "../../integration-api/index.js";
|
|
3
3
|
import { INTEGRATION_FILES } from "../../../models/files.js";
|
|
4
4
|
import { race } from "../../../helpers/race.js";
|
|
5
5
|
/**
|
|
@@ -153,7 +153,9 @@ export class FileWatcher {
|
|
|
153
153
|
}, { signal });
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
|
-
* fileWatcherCallback that will reinstall the serviceWorker
|
|
156
|
+
* fileWatcherCallback that will reinstall the serviceWorker.
|
|
157
|
+
* With the `enableSpeedKitConfigPlugins` feature, the document handler embeds `config_SpeedKit`,
|
|
158
|
+
* so a change to that file also rebuilds the document handler and drops its cache.
|
|
157
159
|
*
|
|
158
160
|
* @param file
|
|
159
161
|
* @param page
|
|
@@ -166,6 +168,11 @@ export class FileWatcher {
|
|
|
166
168
|
// clear speed-kit-service-worker-caches and uninstall serviceWorker
|
|
167
169
|
await this.safeClearPageBrowsersCacheStorage(page);
|
|
168
170
|
await this.unregisterServiceWorker(page);
|
|
171
|
+
if (file.name === INTEGRATION_FILES.CONFIG.SPEED_KIT &&
|
|
172
|
+
usesConfigPlugins(this.customerConfig)) {
|
|
173
|
+
await this.documentHandler.buildDocumentHandler();
|
|
174
|
+
this.clearOrRefreshCache(page);
|
|
175
|
+
}
|
|
169
176
|
// rebuild installResource
|
|
170
177
|
await installResource.buildContent();
|
|
171
178
|
// tell puppeteer to reinstall serviceworker on next navigate
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
|
+
import { FileWatcher } from "../../file-events/file-watcher.js";
|
|
4
|
+
import { INTEGRATION_FILES } from "../../../../models/files.js";
|
|
5
|
+
/**
|
|
6
|
+
* Builds a FileWatcher with fakes and returns what it did on a change of `config_SpeedKit`.
|
|
7
|
+
*
|
|
8
|
+
* @param features the features of the customer config
|
|
9
|
+
*/
|
|
10
|
+
async function changeSpeedKitConfig(features) {
|
|
11
|
+
const calls = [];
|
|
12
|
+
const callbacks = new Map();
|
|
13
|
+
const file = (name) => ({
|
|
14
|
+
name,
|
|
15
|
+
type: "file",
|
|
16
|
+
onChange: (callback) => callbacks.set(name, callback),
|
|
17
|
+
});
|
|
18
|
+
const files = {
|
|
19
|
+
hasFile: (name) => name === INTEGRATION_FILES.CONFIG.SPEED_KIT,
|
|
20
|
+
getByName: (name) => name === INTEGRATION_FILES.BUILD.INSTALL
|
|
21
|
+
? {
|
|
22
|
+
buildContent: async () => calls.push("buildInstallResource"),
|
|
23
|
+
}
|
|
24
|
+
: file(name),
|
|
25
|
+
};
|
|
26
|
+
const page = {
|
|
27
|
+
url: () => "https://www.example.com/products/1",
|
|
28
|
+
target: () => ({
|
|
29
|
+
createCDPSession: async () => ({
|
|
30
|
+
send: async (method) => method === "CacheStorage.requestCacheNames" ? { caches: [] } : {},
|
|
31
|
+
}),
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
const watcher = new FileWatcher({
|
|
35
|
+
writeWarning: () => undefined,
|
|
36
|
+
writeError: () => undefined,
|
|
37
|
+
}, { app: "example", features }, files, {
|
|
38
|
+
buildDocumentHandler: async () => calls.push("buildDocumentHandler"),
|
|
39
|
+
}, { domain: "https://www.example.com" }, { clear: () => calls.push("clearCache") });
|
|
40
|
+
watcher.addCallbackOnFileChange(page, async () => {
|
|
41
|
+
calls.push("reinstallServiceWorker");
|
|
42
|
+
}, new AbortController().signal);
|
|
43
|
+
await callbacks.get(INTEGRATION_FILES.CONFIG.SPEED_KIT)(file(INTEGRATION_FILES.CONFIG.SPEED_KIT));
|
|
44
|
+
return calls;
|
|
45
|
+
}
|
|
46
|
+
describe("FileWatcher", () => {
|
|
47
|
+
describe("on a change of config_SpeedKit", () => {
|
|
48
|
+
it("rebuilds the document handler when it embeds the config", async () => {
|
|
49
|
+
const calls = await changeSpeedKitConfig({
|
|
50
|
+
enableSpeedKitConfigPlugins: true,
|
|
51
|
+
});
|
|
52
|
+
expect(calls).to.deep.equal([
|
|
53
|
+
"buildDocumentHandler",
|
|
54
|
+
"clearCache",
|
|
55
|
+
"buildInstallResource",
|
|
56
|
+
"reinstallServiceWorker",
|
|
57
|
+
]);
|
|
58
|
+
});
|
|
59
|
+
it("only reinstalls the service worker without config plugins", async () => {
|
|
60
|
+
const calls = await changeSpeedKitConfig(undefined);
|
|
61
|
+
expect(calls).to.deep.equal([
|
|
62
|
+
"buildInstallResource",
|
|
63
|
+
"reinstallServiceWorker",
|
|
64
|
+
]);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speedkit/cli",
|
|
3
3
|
"description": "Speed Kit CLI",
|
|
4
|
-
"version": "4.44.0-beta.
|
|
4
|
+
"version": "4.44.0-beta.5",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Baqend.com",
|
|
7
7
|
"email": "info@baqend.com"
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"@oclif/plugin-help": "^6.2.45",
|
|
111
111
|
"@oclif/plugin-not-found": "^3.2.81",
|
|
112
112
|
"@oclif/plugin-warn-if-update-available": "^3.1.61",
|
|
113
|
-
"@speedkit/packjockel": "
|
|
113
|
+
"@speedkit/packjockel": "4.0.0",
|
|
114
114
|
"@speedkit/rules": "^1.3.0-0",
|
|
115
115
|
"baqend": "^4.2.5",
|
|
116
116
|
"chalk": "^5.6.2",
|