@speedkit/cli 4.50.1 → 4.50.3

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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [4.50.3](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.50.2...v4.50.3) (2026-11-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **origin-request:** send the host header of an origin map entry ([22eff25](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/22eff257fbb89c6d2bb64d36f947cd39bb35e738))
7
+
8
+ ## [4.50.2](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.50.1...v4.50.2) (2026-10-29)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **diff:** treat a null content as empty in the equality check ([9986540](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/9986540048c2243d338cfe54c9807eae6c1d2c76))
14
+
1
15
  ## [4.50.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.50.0...v4.50.1) (2026-10-27)
2
16
 
3
17
 
@@ -195,7 +195,11 @@ export function originFetch(url, init, options = {}) {
195
195
  export function directOriginFetch(url, init, options = {}) {
196
196
  const sent = new Headers(init?.headers);
197
197
  const added = FETCH_DEFAULT_HEADERS.filter((name) => !sent.has(name));
198
- const dispatcher = originDispatcher(options.tolerateLegacyTls === true).compose(withoutHeaders(added));
198
+ const host = sent.get("host");
199
+ const interceptors = [withoutHeaders(added)];
200
+ if (host)
201
+ interceptors.push(withHost(host, new URL(url).origin));
202
+ const dispatcher = originDispatcher(options.tolerateLegacyTls === true).compose(interceptors);
199
203
  const request = { ...init, dispatcher };
200
204
  return undiciFetch(url, request);
201
205
  }
@@ -216,6 +220,44 @@ function withoutHeaders(names) {
216
220
  return dispatch({ ...opts, headers: Object.fromEntries(kept) }, handler);
217
221
  };
218
222
  }
223
+ /**
224
+ * Sends the caller's `host` header, which fetch drops as a forbidden header. An origin map entry
225
+ * with `overrideHostHeader` needs it, because its reverse proxy routes by the original host.
226
+ *
227
+ * Only requests to `origin` get it, so a redirect to another origin keeps its own host.
228
+ *
229
+ * The TLS servername stays the connected host. Undici derives it from the `host` header otherwise,
230
+ * and the certificate of the mapped origin does not cover the original host.
231
+ */
232
+ function withHost(host, origin) {
233
+ return (dispatch) => (opts, handler) => {
234
+ const connected = new URL(opts.origin);
235
+ if (connected.origin !== origin)
236
+ return dispatch(opts, handler);
237
+ const headers = Object.fromEntries(headerEntries(opts.headers).filter(([name]) => name.toLowerCase() !== "host"));
238
+ headers.host = host;
239
+ // Undici reads `servername` per request, but its types do not declare it.
240
+ const next = {
241
+ ...opts,
242
+ headers,
243
+ servername: connected.hostname,
244
+ };
245
+ return dispatch(next, handler);
246
+ };
247
+ }
248
+ /** Reads dispatch headers, which arrive as a plain object or as a flat name-value array. */
249
+ function headerEntries(headers) {
250
+ if (!headers)
251
+ return [];
252
+ if (Array.isArray(headers)) {
253
+ const entries = [];
254
+ for (let i = 0; i < headers.length; i += 2) {
255
+ entries.push([String(headers[i]), String(headers[i + 1])]);
256
+ }
257
+ return entries;
258
+ }
259
+ return Object.entries(headers).map(([name, value]) => [name, String(value)]);
260
+ }
219
261
  function currentState() {
220
262
  if (!state) {
221
263
  applyOriginProxy();
@@ -1,8 +1,16 @@
1
1
  import { expect } from "chai";
2
2
  import { describe, beforeEach, afterEach, it } from "mocha";
3
+ import { readFileSync } from "node:fs";
3
4
  import http from "node:http";
5
+ import https from "node:https";
6
+ import { join, dirname } from "node:path";
7
+ import { fileURLToPath } from "node:url";
4
8
  import zlib from "node:zlib";
5
9
  import { applyOriginProxy, chromeProxyFlag, findProxyInChromeFlags, originFetch, parseSocksProxy, PROXY_ENVIRONMENT_VARIABLE, resetOriginProxy, setOriginProxy, withOriginProxyFlag, } from "../origin-proxy.js";
10
+ /** Self-signed for `localhost`, only to serve the TLS spec. */
11
+ const FIXTURES = join(dirname(fileURLToPath(import.meta.url)), "fixtures");
12
+ const LOCALHOST_KEY = readFileSync(join(FIXTURES, "localhost.key"), "utf8");
13
+ const LOCALHOST_CERT = readFileSync(join(FIXTURES, "localhost.crt"), "utf8");
6
14
  /** Sets or clears the enforcing environment variable. */
7
15
  function setEnvironmentProxy(value) {
8
16
  if (value === undefined) {
@@ -168,6 +176,10 @@ describe("origin proxy", () => {
168
176
  if (request.url === "/redirect") {
169
177
  response.writeHead(302, { location: "/" }).end();
170
178
  }
179
+ else if (request.url.startsWith("/redirect-to?")) {
180
+ const location = decodeURIComponent(request.url.split("?")[1]);
181
+ response.writeHead(302, { location }).end();
182
+ }
171
183
  else if (request.url === "/missing") {
172
184
  response.writeHead(404).end(body);
173
185
  }
@@ -208,6 +220,22 @@ describe("origin proxy", () => {
208
220
  expect(headers["accept-language"]).to.equal("en-GB");
209
221
  expect(headers.accept).to.equal("text/html");
210
222
  });
223
+ it("sends the host header the caller sets", async () => {
224
+ const headers = await received("", {
225
+ headers: { Host: "www.example.com" },
226
+ });
227
+ expect(headers.host).to.equal("www.example.com");
228
+ });
229
+ it("keeps the host header off a redirect to another origin", async () => {
230
+ const other = echoUrl.replace("127.0.0.1", "localhost");
231
+ const response = await originFetch(`${echoUrl}redirect-to?${encodeURIComponent(other)}`, { headers: { host: "www.example.com" } });
232
+ expect(response.url).to.equal(other);
233
+ expect((await response.json()).host).to.equal(new URL(other).host);
234
+ });
235
+ it("sends the url's host without a host header", async () => {
236
+ const headers = await received();
237
+ expect(headers.host).to.equal(new URL(echoUrl).host);
238
+ });
211
239
  it("drops the defaults when legacy tls is tolerated as well", async () => {
212
240
  const headers = await received("", undefined, {
213
241
  tolerateLegacyTls: true,
@@ -242,6 +270,31 @@ describe("origin proxy", () => {
242
270
  expect(failure?.name).to.equal("TimeoutError");
243
271
  });
244
272
  });
273
+ describe("over tls", () => {
274
+ let secure;
275
+ let secureUrl;
276
+ beforeEach(async () => {
277
+ // Answers the host header and the servername the client sent.
278
+ secure = https.createServer({ key: LOCALHOST_KEY, cert: LOCALHOST_CERT }, (request, response) => response.end(JSON.stringify({
279
+ host: request.headers.host,
280
+ servername: request.socket.servername,
281
+ })));
282
+ await new Promise((resolve) => secure.listen(0, resolve));
283
+ secureUrl = `https://localhost:${secure.address().port}/`;
284
+ });
285
+ afterEach(() => {
286
+ secure.closeAllConnections();
287
+ secure.close();
288
+ });
289
+ it("keeps the connected host as servername when it overrides the host header", async () => {
290
+ // The self-signed certificate needs the tolerant transport.
291
+ const response = await originFetch(secureUrl, { headers: { host: "www.example.com" } }, { tolerateLegacyTls: true });
292
+ expect(await response.json()).to.deep.equal({
293
+ host: "www.example.com",
294
+ servername: "localhost",
295
+ });
296
+ });
297
+ });
245
298
  it("routes through the installed proxy", async () => {
246
299
  // Nothing listens on port 1, so a proxied request must fail to connect.
247
300
  setOriginProxy({ type: 5, host: "127.0.0.1", port: 1 });
@@ -11,8 +11,11 @@ export interface DiffEngineDeps {
11
11
  export declare class DiffEngine {
12
12
  private readonly deps;
13
13
  constructor(deps: DiffEngineDeps);
14
- /** Whether the two contents are equal once all whitespace is removed. */
15
- isContentEqual(left?: string, right?: string): boolean;
14
+ /**
15
+ * Whether the two contents are equal once all whitespace is removed.
16
+ * A null content counts as empty: an unset install field holds null.
17
+ */
18
+ isContentEqual(left?: string | null, right?: string | null): boolean;
16
19
  compare(left: DiffSide, right: DiffSide): Promise<DiffResult>;
17
20
  /**
18
21
  * Compares a remote content with its local counterpart, as a deploy does.
@@ -13,9 +13,13 @@ export class DiffEngine {
13
13
  constructor(deps) {
14
14
  this.deps = deps;
15
15
  }
16
- /** Whether the two contents are equal once all whitespace is removed. */
16
+ /**
17
+ * Whether the two contents are equal once all whitespace is removed.
18
+ * A null content counts as empty: an unset install field holds null.
19
+ */
17
20
  isContentEqual(left = "", right = "") {
18
- return left.replaceAll(/\s/g, "") === right.replaceAll(/\s/g, "");
21
+ const strip = (content) => (content ?? "").replaceAll(/\s/g, "");
22
+ return strip(left) === strip(right);
19
23
  }
20
24
  async compare(left, right) {
21
25
  const result = {
@@ -44,4 +44,15 @@ describe("DiffEngine", () => {
44
44
  const result = await engine.compare({ label: "a", content: undefined }, { label: "b", content: "" });
45
45
  expect(result.equal).to.equal(true);
46
46
  });
47
+ it("treats a null remote content as empty, as an unset install field holds", async () => {
48
+ const engine = new DiffEngine({ sink: recordingSink() });
49
+ const { equal, updatedFile } = await engine.diffContent("config_dynamicStyles.css", null, "body {}");
50
+ expect(equal).to.equal(false);
51
+ expect(updatedFile).to.equal("body {}");
52
+ });
53
+ it("treats a null content as empty in an equality check", () => {
54
+ const engine = new DiffEngine({ sink: recordingSink() });
55
+ expect(engine.isContentEqual(null, " \n")).to.equal(true);
56
+ expect(engine.isContentEqual("a", null)).to.equal(false);
57
+ });
47
58
  });
@@ -1495,6 +1495,149 @@
1495
1495
  "setup.js"
1496
1496
  ]
1497
1497
  },
1498
+ "extension:add": {
1499
+ "aliases": [],
1500
+ "args": {
1501
+ "ref": {
1502
+ "description": "Chrome Web Store link or extension id",
1503
+ "name": "ref",
1504
+ "required": false
1505
+ }
1506
+ },
1507
+ "description": "Install a Chrome extension into the onboarding browser by Web Store link or id",
1508
+ "examples": [
1509
+ "$ sk extension add fmkadmapgofadopljbjfkapdkoienihi",
1510
+ "$ sk extension add https://chromewebstore.google.com/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi",
1511
+ "$ sk extension add"
1512
+ ],
1513
+ "flags": {},
1514
+ "hasDynamicHelp": false,
1515
+ "hiddenAliases": [],
1516
+ "id": "extension:add",
1517
+ "pluginAlias": "@speedkit/cli",
1518
+ "pluginName": "@speedkit/cli",
1519
+ "pluginType": "core",
1520
+ "strict": true,
1521
+ "enableJsonFlag": false,
1522
+ "isESM": true,
1523
+ "relativePath": [
1524
+ "dist",
1525
+ "commands",
1526
+ "extension",
1527
+ "add.js"
1528
+ ]
1529
+ },
1530
+ "extension:devtools": {
1531
+ "aliases": [],
1532
+ "args": {},
1533
+ "description": "Install the integration-devtools extension for the onboarding browser, or update it to the latest release",
1534
+ "examples": [
1535
+ "$ sk extension devtools",
1536
+ "$ sk extension devtools --force"
1537
+ ],
1538
+ "flags": {
1539
+ "force": {
1540
+ "description": "reinstall the latest release even when it is up to date",
1541
+ "name": "force",
1542
+ "allowNo": false,
1543
+ "type": "boolean"
1544
+ }
1545
+ },
1546
+ "hasDynamicHelp": false,
1547
+ "hiddenAliases": [],
1548
+ "id": "extension:devtools",
1549
+ "pluginAlias": "@speedkit/cli",
1550
+ "pluginName": "@speedkit/cli",
1551
+ "pluginType": "core",
1552
+ "strict": true,
1553
+ "enableJsonFlag": false,
1554
+ "isESM": true,
1555
+ "relativePath": [
1556
+ "dist",
1557
+ "commands",
1558
+ "extension",
1559
+ "devtools.js"
1560
+ ]
1561
+ },
1562
+ "extension:list": {
1563
+ "aliases": [],
1564
+ "args": {},
1565
+ "description": "List Chrome extensions managed by the setup wizard",
1566
+ "examples": [
1567
+ "$ sk extension list"
1568
+ ],
1569
+ "flags": {},
1570
+ "hasDynamicHelp": false,
1571
+ "hiddenAliases": [],
1572
+ "id": "extension:list",
1573
+ "pluginAlias": "@speedkit/cli",
1574
+ "pluginName": "@speedkit/cli",
1575
+ "pluginType": "core",
1576
+ "strict": true,
1577
+ "enableJsonFlag": false,
1578
+ "isESM": true,
1579
+ "relativePath": [
1580
+ "dist",
1581
+ "commands",
1582
+ "extension",
1583
+ "list.js"
1584
+ ]
1585
+ },
1586
+ "extension:remove": {
1587
+ "aliases": [],
1588
+ "args": {
1589
+ "ref": {
1590
+ "description": "Chrome Web Store link or extension id",
1591
+ "name": "ref",
1592
+ "required": false
1593
+ }
1594
+ },
1595
+ "description": "Remove a managed Chrome extension",
1596
+ "examples": [
1597
+ "$ sk extension remove",
1598
+ "$ sk extension remove <id>"
1599
+ ],
1600
+ "flags": {},
1601
+ "hasDynamicHelp": false,
1602
+ "hiddenAliases": [],
1603
+ "id": "extension:remove",
1604
+ "pluginAlias": "@speedkit/cli",
1605
+ "pluginName": "@speedkit/cli",
1606
+ "pluginType": "core",
1607
+ "strict": true,
1608
+ "enableJsonFlag": false,
1609
+ "isESM": true,
1610
+ "relativePath": [
1611
+ "dist",
1612
+ "commands",
1613
+ "extension",
1614
+ "remove.js"
1615
+ ]
1616
+ },
1617
+ "extension:update": {
1618
+ "aliases": [],
1619
+ "args": {},
1620
+ "description": "Check managed Chrome extensions for updates and install them",
1621
+ "examples": [
1622
+ "$ sk extension update"
1623
+ ],
1624
+ "flags": {},
1625
+ "hasDynamicHelp": false,
1626
+ "hiddenAliases": [],
1627
+ "id": "extension:update",
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
+ "extension",
1638
+ "update.js"
1639
+ ]
1640
+ },
1498
1641
  "query:parameter": {
1499
1642
  "aliases": [
1500
1643
  "build-parameter-query"
@@ -1806,149 +1949,6 @@
1806
1949
  "prewarm.js"
1807
1950
  ]
1808
1951
  },
1809
- "extension:add": {
1810
- "aliases": [],
1811
- "args": {
1812
- "ref": {
1813
- "description": "Chrome Web Store link or extension id",
1814
- "name": "ref",
1815
- "required": false
1816
- }
1817
- },
1818
- "description": "Install a Chrome extension into the onboarding browser by Web Store link or id",
1819
- "examples": [
1820
- "$ sk extension add fmkadmapgofadopljbjfkapdkoienihi",
1821
- "$ sk extension add https://chromewebstore.google.com/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi",
1822
- "$ sk extension add"
1823
- ],
1824
- "flags": {},
1825
- "hasDynamicHelp": false,
1826
- "hiddenAliases": [],
1827
- "id": "extension:add",
1828
- "pluginAlias": "@speedkit/cli",
1829
- "pluginName": "@speedkit/cli",
1830
- "pluginType": "core",
1831
- "strict": true,
1832
- "enableJsonFlag": false,
1833
- "isESM": true,
1834
- "relativePath": [
1835
- "dist",
1836
- "commands",
1837
- "extension",
1838
- "add.js"
1839
- ]
1840
- },
1841
- "extension:devtools": {
1842
- "aliases": [],
1843
- "args": {},
1844
- "description": "Install the integration-devtools extension for the onboarding browser, or update it to the latest release",
1845
- "examples": [
1846
- "$ sk extension devtools",
1847
- "$ sk extension devtools --force"
1848
- ],
1849
- "flags": {
1850
- "force": {
1851
- "description": "reinstall the latest release even when it is up to date",
1852
- "name": "force",
1853
- "allowNo": false,
1854
- "type": "boolean"
1855
- }
1856
- },
1857
- "hasDynamicHelp": false,
1858
- "hiddenAliases": [],
1859
- "id": "extension:devtools",
1860
- "pluginAlias": "@speedkit/cli",
1861
- "pluginName": "@speedkit/cli",
1862
- "pluginType": "core",
1863
- "strict": true,
1864
- "enableJsonFlag": false,
1865
- "isESM": true,
1866
- "relativePath": [
1867
- "dist",
1868
- "commands",
1869
- "extension",
1870
- "devtools.js"
1871
- ]
1872
- },
1873
- "extension:list": {
1874
- "aliases": [],
1875
- "args": {},
1876
- "description": "List Chrome extensions managed by the setup wizard",
1877
- "examples": [
1878
- "$ sk extension list"
1879
- ],
1880
- "flags": {},
1881
- "hasDynamicHelp": false,
1882
- "hiddenAliases": [],
1883
- "id": "extension:list",
1884
- "pluginAlias": "@speedkit/cli",
1885
- "pluginName": "@speedkit/cli",
1886
- "pluginType": "core",
1887
- "strict": true,
1888
- "enableJsonFlag": false,
1889
- "isESM": true,
1890
- "relativePath": [
1891
- "dist",
1892
- "commands",
1893
- "extension",
1894
- "list.js"
1895
- ]
1896
- },
1897
- "extension:remove": {
1898
- "aliases": [],
1899
- "args": {
1900
- "ref": {
1901
- "description": "Chrome Web Store link or extension id",
1902
- "name": "ref",
1903
- "required": false
1904
- }
1905
- },
1906
- "description": "Remove a managed Chrome extension",
1907
- "examples": [
1908
- "$ sk extension remove",
1909
- "$ sk extension remove <id>"
1910
- ],
1911
- "flags": {},
1912
- "hasDynamicHelp": false,
1913
- "hiddenAliases": [],
1914
- "id": "extension:remove",
1915
- "pluginAlias": "@speedkit/cli",
1916
- "pluginName": "@speedkit/cli",
1917
- "pluginType": "core",
1918
- "strict": true,
1919
- "enableJsonFlag": false,
1920
- "isESM": true,
1921
- "relativePath": [
1922
- "dist",
1923
- "commands",
1924
- "extension",
1925
- "remove.js"
1926
- ]
1927
- },
1928
- "extension:update": {
1929
- "aliases": [],
1930
- "args": {},
1931
- "description": "Check managed Chrome extensions for updates and install them",
1932
- "examples": [
1933
- "$ sk extension update"
1934
- ],
1935
- "flags": {},
1936
- "hasDynamicHelp": false,
1937
- "hiddenAliases": [],
1938
- "id": "extension:update",
1939
- "pluginAlias": "@speedkit/cli",
1940
- "pluginName": "@speedkit/cli",
1941
- "pluginType": "core",
1942
- "strict": true,
1943
- "enableJsonFlag": false,
1944
- "isESM": true,
1945
- "relativePath": [
1946
- "dist",
1947
- "commands",
1948
- "extension",
1949
- "update.js"
1950
- ]
1951
- },
1952
1952
  "revalidate:jobs": {
1953
1953
  "aliases": [],
1954
1954
  "args": {
@@ -2113,5 +2113,5 @@
2113
2113
  ]
2114
2114
  }
2115
2115
  },
2116
- "version": "4.50.1"
2116
+ "version": "4.50.3"
2117
2117
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "4.50.1",
4
+ "version": "4.50.3",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"