@speedkit/cli 4.51.0 → 4.51.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/fetch-events/spec/speed-kit-install-js.spec.d.ts +1 -0
- package/dist/services/onboarding/fetch-events/spec/speed-kit-install-js.spec.js +59 -0
- package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +5 -3
- package/oclif.manifest.json +65 -65
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [4.51.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.51.0...v4.51.1) (2026-11-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **onboarding:** bound worker version queries to the worker URL ([062152d](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/062152d36ff3634aa8b45e4b13167bb6dfda2b62))
|
|
7
|
+
|
|
1
8
|
# [4.51.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.50.5...v4.51.0) (2026-11-10)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
|
+
import { Script } from "node:vm";
|
|
4
|
+
import { SpeedKitInstallJs } from "../speed-kit-install-js.js";
|
|
5
|
+
const domain = "fixture.app.baqend.com";
|
|
6
|
+
const worker = "/apps/speed-kit/sw.js";
|
|
7
|
+
const local = "window.speedKit = {sw: " + JSON.stringify(worker) + "};";
|
|
8
|
+
async function render(remote, base64Encoded = false) {
|
|
9
|
+
const handler = new SpeedKitInstallJs({ appDomain: domain }, { getContent: () => local }, {
|
|
10
|
+
comment: () => undefined,
|
|
11
|
+
writeError: () => undefined,
|
|
12
|
+
});
|
|
13
|
+
const event = {
|
|
14
|
+
requestId: "remote-install-response",
|
|
15
|
+
request: { url: "https://" + domain + "/v1/speedkit/install.js" },
|
|
16
|
+
responseStatusCode: 200,
|
|
17
|
+
responseHeaders: [],
|
|
18
|
+
};
|
|
19
|
+
const client = {
|
|
20
|
+
send: async (method, parameters) => {
|
|
21
|
+
expect(method).to.equal("Fetch.getResponseBody");
|
|
22
|
+
expect(parameters.requestId).to.equal(event.requestId);
|
|
23
|
+
return {
|
|
24
|
+
base64Encoded,
|
|
25
|
+
body: base64Encoded ? Buffer.from(remote).toString("base64") : remote,
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const response = await handler.handle(event, client);
|
|
30
|
+
if (!response || !("body" in response)) {
|
|
31
|
+
throw new Error("The valid install response was not fulfilled");
|
|
32
|
+
}
|
|
33
|
+
return Buffer.from(response.body, "base64").toString("utf8");
|
|
34
|
+
}
|
|
35
|
+
describe("SpeedKitInstallJs", () => {
|
|
36
|
+
it("keeps a queryless worker unchanged when a later search example contains a query", async () => {
|
|
37
|
+
const remote = 'window.speedKit = {sw: "/apps/speed-kit/sw.js",\n' +
|
|
38
|
+
'blacklist: [/search/i, // e.g. /search?q=rucksack\n"/pages/"]};';
|
|
39
|
+
const rendered = await render(remote);
|
|
40
|
+
expect(rendered).to.equal(local);
|
|
41
|
+
expect(() => new Script(rendered)).not.to.throw();
|
|
42
|
+
});
|
|
43
|
+
for (const query of [
|
|
44
|
+
"?r=declared-version&v=2.22.0&gr=A",
|
|
45
|
+
"?r=version&literal=$$-$&-$'",
|
|
46
|
+
]) {
|
|
47
|
+
for (const base64 of [false, true]) {
|
|
48
|
+
it("preserves the worker query " + JSON.stringify({ query, base64 }), async () => {
|
|
49
|
+
const remote = "window.speedKit = {sw: " + JSON.stringify(worker + query) + "};";
|
|
50
|
+
const rendered = await render(remote, base64);
|
|
51
|
+
expect(rendered).to.equal(remote);
|
|
52
|
+
expect(() => new Script(rendered)).not.to.throw();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
it("leaves the local worker unchanged when the remote declaration is absent", async () => {
|
|
57
|
+
expect(await render('const search = "/search?q=rucksack";')).to.equal(local);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -36,8 +36,8 @@ export class SpeedKitInstallJs {
|
|
|
36
36
|
const configVersion = await this.extractConfigVersion(client, event);
|
|
37
37
|
if (configVersion) {
|
|
38
38
|
// append remote serviceWorkerParams to localVersion
|
|
39
|
-
installJs = installJs.replace(
|
|
40
|
-
return matched.replace(selected, selected + configVersion);
|
|
39
|
+
installJs = installJs.replace(/\bsw\s*:\s*"([^"\r\n]*)"/, (matched, selected) => {
|
|
40
|
+
return matched.replace(selected, () => selected + configVersion);
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
return new BaqendResponse(installJs, "text/javascript; charset=utf-8", event.responseHeaders);
|
|
@@ -53,7 +53,9 @@ export class SpeedKitInstallJs {
|
|
|
53
53
|
this.cli.writeError(`could not fetch install resource: "${event.request.url}": ${originBodyResponse.error}`);
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
// Bound the query to the worker literal before its closing quote.
|
|
57
|
+
const [, configVersion] = originBodyResponse.data.match(/\bsw\s*:\s*"[^"?\r\n]*(\?[^"\r\n]*)"/) ||
|
|
58
|
+
[];
|
|
57
59
|
return configVersion;
|
|
58
60
|
}
|
|
59
61
|
async getContent(client, event) {
|
package/oclif.manifest.json
CHANGED
|
@@ -1431,70 +1431,6 @@
|
|
|
1431
1431
|
"update.js"
|
|
1432
1432
|
]
|
|
1433
1433
|
},
|
|
1434
|
-
"config:edit": {
|
|
1435
|
-
"aliases": [],
|
|
1436
|
-
"args": {},
|
|
1437
|
-
"description": "Edit cli config",
|
|
1438
|
-
"examples": [
|
|
1439
|
-
"$ sk config edit"
|
|
1440
|
-
],
|
|
1441
|
-
"flags": {},
|
|
1442
|
-
"hasDynamicHelp": false,
|
|
1443
|
-
"hiddenAliases": [],
|
|
1444
|
-
"id": "config:edit",
|
|
1445
|
-
"pluginAlias": "@speedkit/cli",
|
|
1446
|
-
"pluginName": "@speedkit/cli",
|
|
1447
|
-
"pluginType": "core",
|
|
1448
|
-
"strict": true,
|
|
1449
|
-
"enableJsonFlag": false,
|
|
1450
|
-
"isESM": true,
|
|
1451
|
-
"relativePath": [
|
|
1452
|
-
"dist",
|
|
1453
|
-
"commands",
|
|
1454
|
-
"config",
|
|
1455
|
-
"edit.js"
|
|
1456
|
-
]
|
|
1457
|
-
},
|
|
1458
|
-
"config:setup": {
|
|
1459
|
-
"aliases": [],
|
|
1460
|
-
"args": {},
|
|
1461
|
-
"description": "Run the Speed Kit CLI setup wizard (choose browser and diff tool)",
|
|
1462
|
-
"examples": [
|
|
1463
|
-
"$ sk config setup",
|
|
1464
|
-
"$ sk config setup --force"
|
|
1465
|
-
],
|
|
1466
|
-
"flags": {
|
|
1467
|
-
"force": {
|
|
1468
|
-
"char": "f",
|
|
1469
|
-
"description": "Re-run even if setup was already completed",
|
|
1470
|
-
"name": "force",
|
|
1471
|
-
"allowNo": false,
|
|
1472
|
-
"type": "boolean"
|
|
1473
|
-
},
|
|
1474
|
-
"postInstall": {
|
|
1475
|
-
"description": "Internal flag used by the npm postinstall hook",
|
|
1476
|
-
"hidden": true,
|
|
1477
|
-
"name": "postInstall",
|
|
1478
|
-
"allowNo": false,
|
|
1479
|
-
"type": "boolean"
|
|
1480
|
-
}
|
|
1481
|
-
},
|
|
1482
|
-
"hasDynamicHelp": false,
|
|
1483
|
-
"hiddenAliases": [],
|
|
1484
|
-
"id": "config:setup",
|
|
1485
|
-
"pluginAlias": "@speedkit/cli",
|
|
1486
|
-
"pluginName": "@speedkit/cli",
|
|
1487
|
-
"pluginType": "core",
|
|
1488
|
-
"strict": true,
|
|
1489
|
-
"enableJsonFlag": false,
|
|
1490
|
-
"isESM": true,
|
|
1491
|
-
"relativePath": [
|
|
1492
|
-
"dist",
|
|
1493
|
-
"commands",
|
|
1494
|
-
"config",
|
|
1495
|
-
"setup.js"
|
|
1496
|
-
]
|
|
1497
|
-
},
|
|
1498
1434
|
"extension:add": {
|
|
1499
1435
|
"aliases": [],
|
|
1500
1436
|
"args": {
|
|
@@ -1638,6 +1574,70 @@
|
|
|
1638
1574
|
"update.js"
|
|
1639
1575
|
]
|
|
1640
1576
|
},
|
|
1577
|
+
"config:edit": {
|
|
1578
|
+
"aliases": [],
|
|
1579
|
+
"args": {},
|
|
1580
|
+
"description": "Edit cli config",
|
|
1581
|
+
"examples": [
|
|
1582
|
+
"$ sk config edit"
|
|
1583
|
+
],
|
|
1584
|
+
"flags": {},
|
|
1585
|
+
"hasDynamicHelp": false,
|
|
1586
|
+
"hiddenAliases": [],
|
|
1587
|
+
"id": "config:edit",
|
|
1588
|
+
"pluginAlias": "@speedkit/cli",
|
|
1589
|
+
"pluginName": "@speedkit/cli",
|
|
1590
|
+
"pluginType": "core",
|
|
1591
|
+
"strict": true,
|
|
1592
|
+
"enableJsonFlag": false,
|
|
1593
|
+
"isESM": true,
|
|
1594
|
+
"relativePath": [
|
|
1595
|
+
"dist",
|
|
1596
|
+
"commands",
|
|
1597
|
+
"config",
|
|
1598
|
+
"edit.js"
|
|
1599
|
+
]
|
|
1600
|
+
},
|
|
1601
|
+
"config:setup": {
|
|
1602
|
+
"aliases": [],
|
|
1603
|
+
"args": {},
|
|
1604
|
+
"description": "Run the Speed Kit CLI setup wizard (choose browser and diff tool)",
|
|
1605
|
+
"examples": [
|
|
1606
|
+
"$ sk config setup",
|
|
1607
|
+
"$ sk config setup --force"
|
|
1608
|
+
],
|
|
1609
|
+
"flags": {
|
|
1610
|
+
"force": {
|
|
1611
|
+
"char": "f",
|
|
1612
|
+
"description": "Re-run even if setup was already completed",
|
|
1613
|
+
"name": "force",
|
|
1614
|
+
"allowNo": false,
|
|
1615
|
+
"type": "boolean"
|
|
1616
|
+
},
|
|
1617
|
+
"postInstall": {
|
|
1618
|
+
"description": "Internal flag used by the npm postinstall hook",
|
|
1619
|
+
"hidden": true,
|
|
1620
|
+
"name": "postInstall",
|
|
1621
|
+
"allowNo": false,
|
|
1622
|
+
"type": "boolean"
|
|
1623
|
+
}
|
|
1624
|
+
},
|
|
1625
|
+
"hasDynamicHelp": false,
|
|
1626
|
+
"hiddenAliases": [],
|
|
1627
|
+
"id": "config:setup",
|
|
1628
|
+
"pluginAlias": "@speedkit/cli",
|
|
1629
|
+
"pluginName": "@speedkit/cli",
|
|
1630
|
+
"pluginType": "core",
|
|
1631
|
+
"strict": true,
|
|
1632
|
+
"enableJsonFlag": false,
|
|
1633
|
+
"isESM": true,
|
|
1634
|
+
"relativePath": [
|
|
1635
|
+
"dist",
|
|
1636
|
+
"commands",
|
|
1637
|
+
"config",
|
|
1638
|
+
"setup.js"
|
|
1639
|
+
]
|
|
1640
|
+
},
|
|
1641
1641
|
"query:parameter": {
|
|
1642
1642
|
"aliases": [
|
|
1643
1643
|
"build-parameter-query"
|
|
@@ -2113,5 +2113,5 @@
|
|
|
2113
2113
|
]
|
|
2114
2114
|
}
|
|
2115
2115
|
},
|
|
2116
|
-
"version": "4.51.
|
|
2116
|
+
"version": "4.51.1"
|
|
2117
2117
|
}
|