wrangler 0.0.0-c3d34906 → 0.0.0-c3ebb24e

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.
Files changed (50) hide show
  1. package/miniflare-dist/index.mjs +42 -49
  2. package/package.json +13 -3
  3. package/src/__tests__/api-dev.test.ts +20 -0
  4. package/src/__tests__/configuration.test.ts +125 -22
  5. package/src/__tests__/dev.test.tsx +0 -2
  6. package/src/__tests__/helpers/mock-oauth-flow.ts +4 -2
  7. package/src/__tests__/index.test.ts +2 -0
  8. package/src/__tests__/paths.test.ts +23 -1
  9. package/src/__tests__/publish.test.ts +8 -10
  10. package/src/__tests__/user.test.ts +4 -4
  11. package/src/__tests__/whoami.test.tsx +0 -1
  12. package/src/__tests__/worker-namespace.test.ts +102 -112
  13. package/src/api/dev.ts +12 -12
  14. package/src/bundle.ts +48 -0
  15. package/src/cfetch/internal.ts +37 -21
  16. package/src/config/environment.ts +20 -0
  17. package/src/config/index.ts +32 -0
  18. package/src/config/validation.ts +59 -0
  19. package/src/config-cache.ts +1 -1
  20. package/src/create-worker-upload-form.ts +9 -0
  21. package/src/d1/backups.tsx +212 -0
  22. package/src/d1/create.tsx +54 -0
  23. package/src/d1/delete.tsx +56 -0
  24. package/src/d1/execute.tsx +294 -0
  25. package/src/d1/formatTimeAgo.ts +14 -0
  26. package/src/d1/index.ts +75 -0
  27. package/src/d1/list.tsx +48 -0
  28. package/src/d1/options.ts +12 -0
  29. package/src/d1/types.tsx +14 -0
  30. package/src/d1/utils.ts +39 -0
  31. package/src/dev/dev.tsx +26 -3
  32. package/src/dev/get-local-persistence-path.tsx +31 -0
  33. package/src/dev/local.tsx +8 -8
  34. package/src/dev/start-server.ts +2 -3
  35. package/src/dev/use-esbuild.ts +8 -1
  36. package/src/dev.tsx +28 -28
  37. package/src/dialogs.tsx +4 -0
  38. package/src/index.tsx +18 -16
  39. package/src/logger.ts +11 -4
  40. package/src/miniflare-cli/index.ts +11 -16
  41. package/src/pages/dev.tsx +13 -9
  42. package/src/paths.ts +30 -4
  43. package/src/proxy.ts +21 -1
  44. package/src/publish.ts +6 -0
  45. package/src/user/user.tsx +1 -0
  46. package/src/worker.ts +30 -0
  47. package/templates/d1-beta-facade.js +174 -0
  48. package/wrangler-dist/cli.d.ts +438 -7
  49. package/wrangler-dist/cli.js +10925 -3223
  50. package/src/miniflare-cli/enum-keys.ts +0 -17
@@ -491,34 +491,6 @@ async function generateHandler({
491
491
  ...Object.fromEntries(existingHeaders.entries()),
492
492
  ...Object.fromEntries(extraHeaders.entries())
493
493
  });
494
- const headersMatcher = generateRulesMatcher(
495
- headerRules,
496
- ({ set = {}, unset = [] }, replacements) => {
497
- const replacedSet = {};
498
- Object.keys(set).forEach((key) => {
499
- replacedSet[key] = replacer(set[key], replacements);
500
- });
501
- return {
502
- set: replacedSet,
503
- unset
504
- };
505
- }
506
- );
507
- const matches = headersMatcher({ request });
508
- const setMap = /* @__PURE__ */ new Set();
509
- matches.forEach(({ set = {}, unset = [] }) => {
510
- Object.keys(set).forEach((key) => {
511
- if (setMap.has(key.toLowerCase())) {
512
- headers.append(key, set[key]);
513
- } else {
514
- headers.set(key, set[key]);
515
- setMap.add(key.toLowerCase());
516
- }
517
- });
518
- unset.forEach((key) => {
519
- headers.delete(key);
520
- });
521
- });
522
494
  if (earlyHintsCache) {
523
495
  const preEarlyHintsHeaders = new Headers(headers);
524
496
  const earlyHintsCacheKey = `${protocol}//${host}${pathname}`;
@@ -539,6 +511,13 @@ async function generateHandler({
539
511
  const links = [];
540
512
  const transformedResponse = new HTMLRewriter().on("link[rel=preconnect],link[rel=preload]", {
541
513
  element(element) {
514
+ for (const [attributeName] of element.attributes) {
515
+ if (!ALLOWED_EARLY_HINT_LINK_ATTRIBUTES.includes(
516
+ attributeName.toLowerCase()
517
+ )) {
518
+ return;
519
+ }
520
+ }
542
521
  const href = element.getAttribute("href") || void 0;
543
522
  const rel = element.getAttribute("rel") || void 0;
544
523
  const as = element.getAttribute("as") || void 0;
@@ -568,6 +547,34 @@ async function generateHandler({
568
547
  );
569
548
  }
570
549
  }
550
+ const headersMatcher = generateRulesMatcher(
551
+ headerRules,
552
+ ({ set = {}, unset = [] }, replacements) => {
553
+ const replacedSet = {};
554
+ Object.keys(set).forEach((key) => {
555
+ replacedSet[key] = replacer(set[key], replacements);
556
+ });
557
+ return {
558
+ set: replacedSet,
559
+ unset
560
+ };
561
+ }
562
+ );
563
+ const matches = headersMatcher({ request });
564
+ const setMap = /* @__PURE__ */ new Set();
565
+ matches.forEach(({ set = {}, unset = [] }) => {
566
+ Object.keys(set).forEach((key) => {
567
+ if (setMap.has(key.toLowerCase())) {
568
+ headers.append(key, set[key]);
569
+ } else {
570
+ headers.set(key, set[key]);
571
+ setMap.add(key.toLowerCase());
572
+ }
573
+ });
574
+ unset.forEach((key) => {
575
+ headers.delete(key);
576
+ });
577
+ });
571
578
  return new Response(
572
579
  [101, 204, 205, 304].includes(response.status) ? null : response.body,
573
580
  {
@@ -716,7 +723,7 @@ function isPreview(url) {
716
723
  }
717
724
  return false;
718
725
  }
719
- var ASSET_PRESERVATION_CACHE, CACHE_CONTROL_PRESERVATION, CACHE_CONTROL_BROWSER, REDIRECTS_VERSION2, HEADERS_VERSION2, HEADERS_VERSION_V1, ANALYTICS_VERSION2;
726
+ var ASSET_PRESERVATION_CACHE, CACHE_CONTROL_PRESERVATION, CACHE_CONTROL_BROWSER, REDIRECTS_VERSION2, HEADERS_VERSION2, HEADERS_VERSION_V1, ANALYTICS_VERSION2, ALLOWED_EARLY_HINT_LINK_ATTRIBUTES;
720
727
  var init_handler = __esm({
721
728
  "../pages-shared/src/asset-server/handler.ts"() {
722
729
  init_responses();
@@ -728,6 +735,7 @@ var init_handler = __esm({
728
735
  HEADERS_VERSION2 = 2;
729
736
  HEADERS_VERSION_V1 = 1;
730
737
  ANALYTICS_VERSION2 = 1;
738
+ ALLOWED_EARLY_HINT_LINK_ATTRIBUTES = ["rel", "as", "href"];
731
739
  }
732
740
  });
733
741
 
@@ -739,7 +747,6 @@ import {
739
747
  } from "@miniflare/durable-objects";
740
748
  import {
741
749
  Log,
742
- LogLevel,
743
750
  Miniflare,
744
751
  Response as MiniflareResponse3,
745
752
  Request as MiniflareRequest3
@@ -6118,18 +6125,6 @@ var invalidAssetsFetch = () => {
6118
6125
  );
6119
6126
  };
6120
6127
 
6121
- // src/miniflare-cli/enum-keys.ts
6122
- var enumObject = (e) => {
6123
- const copy = { ...e };
6124
- Object.values(e).forEach(
6125
- (value) => typeof value === "number" && delete copy[value]
6126
- );
6127
- return copy;
6128
- };
6129
- var enumKeys = (e) => {
6130
- return Object.keys(enumObject(e));
6131
- };
6132
-
6133
6128
  // src/miniflare-cli/request-context.ts
6134
6129
  var getRequestContextCheckOptions = async () => {
6135
6130
  let hasAsyncLocalStorage = true;
@@ -6158,18 +6153,16 @@ var NoOpLog = class extends Log {
6158
6153
  }
6159
6154
  };
6160
6155
  async function main() {
6161
- const args = await yargs_default(hideBin(process.argv)).help(false).version(false).option("log", {
6162
- choices: enumKeys(LogLevel)
6163
- }).argv;
6164
- const logLevel = LogLevel[args.log ?? "INFO"];
6156
+ const args = await yargs_default(hideBin(process.argv)).help(false).version(false).argv;
6165
6157
  const requestContextCheckOptions = await getRequestContextCheckOptions();
6166
6158
  const config = {
6167
6159
  ...JSON.parse(args._[0] ?? "{}"),
6168
6160
  ...requestContextCheckOptions
6169
6161
  };
6170
- config.log = config.disableLogs ? new NoOpLog() : new Log(logLevel, config.logOptions);
6171
- if (logLevel > LogLevel.INFO) {
6172
- console.log("OPTIONS:\n", JSON.stringify(config, null, 2));
6162
+ const logLevel = config.logLevel.toUpperCase();
6163
+ config.log = config.logLevel === "none" ? new NoOpLog() : new Log(logLevel, config.logOptions);
6164
+ if (logLevel === "DEBUG" || logLevel === "VERBOSE") {
6165
+ console.log("MINIFLARE OPTIONS:\n", JSON.stringify(config, null, 2));
6173
6166
  }
6174
6167
  config.bindings = {
6175
6168
  ...config.bindings,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "0.0.0-c3d34906",
3
+ "version": "0.0.0-c3ebb24e",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -87,17 +87,20 @@
87
87
  ]
88
88
  },
89
89
  "transformIgnorePatterns": [
90
- "node_modules/(?!find-up|locate-path|p-locate|p-limit|p-timeout|p-queue|yocto-queue|path-exists|execa|strip-final-newline|npm-run-path|path-key|onetime|mimic-fn|human-signals|is-stream|get-port|supports-color|pretty-bytes)"
90
+ "node_modules/(?!find-up|locate-path|p-locate|p-limit|p-timeout|p-queue|yocto-queue|path-exists|execa|strip-final-newline|npm-run-path|path-key|onetime|mimic-fn|human-signals|is-stream|get-port|supports-color|pretty-bytes|npx-import)"
91
91
  ]
92
92
  },
93
93
  "dependencies": {
94
94
  "@cloudflare/kv-asset-handler": "^0.2.0",
95
95
  "@esbuild-plugins/node-globals-polyfill": "^0.1.1",
96
96
  "@esbuild-plugins/node-modules-polyfill": "^0.1.4",
97
+ "@miniflare/core": "2.9.0",
98
+ "@miniflare/d1": "2.9.0",
99
+ "@miniflare/durable-objects": "2.9.0",
97
100
  "blake3-wasm": "^2.1.5",
98
101
  "chokidar": "^3.5.3",
99
102
  "esbuild": "0.14.51",
100
- "miniflare": "^2.8.1",
103
+ "miniflare": "2.9.0",
101
104
  "nanoid": "^3.3.3",
102
105
  "path-to-regexp": "^6.2.0",
103
106
  "selfsigned": "^2.0.1",
@@ -105,12 +108,16 @@
105
108
  "xxhash-wasm": "^1.0.1"
106
109
  },
107
110
  "devDependencies": {
111
+ "@databases/split-sql-query": "^1.0.3",
112
+ "@databases/sql": "^3.2.0",
108
113
  "@iarna/toml": "^3.0.0",
109
114
  "@microsoft/api-extractor": "^7.28.3",
115
+ "@types/better-sqlite3": "^7.6.0",
110
116
  "@types/busboy": "^1.5.0",
111
117
  "@types/command-exists": "^1.2.0",
112
118
  "@types/express": "^4.17.13",
113
119
  "@types/glob-to-regexp": "0.4.1",
120
+ "@types/javascript-time-ago": "^2.0.3",
114
121
  "@types/mime": "^2.0.3",
115
122
  "@types/prompts": "^2.0.14",
116
123
  "@types/react": "^17.0.37",
@@ -145,16 +152,19 @@
145
152
  "ink-testing-library": "^2.1.0",
146
153
  "ink-text-input": "^4.0.3",
147
154
  "is-ci": "^3.0.1",
155
+ "javascript-time-ago": "^2.5.4",
148
156
  "jest-fetch-mock": "^3.0.3",
149
157
  "jest-websocket-mock": "^2.3.0",
150
158
  "mime": "^3.0.0",
151
159
  "msw": "^0.47.1",
160
+ "npx-import": "^1.0.2",
152
161
  "open": "^8.4.0",
153
162
  "p-queue": "^7.2.0",
154
163
  "pretty-bytes": "^6.0.0",
155
164
  "prompts": "^2.4.2",
156
165
  "react": "^17.0.2",
157
166
  "react-error-boundary": "^3.1.4",
167
+ "remove-accents-esm": "^0.0.1",
158
168
  "serve-static": "^1.15.0",
159
169
  "signal-exit": "^3.0.7",
160
170
  "supports-color": "^9.2.2",
@@ -19,6 +19,26 @@ describe("unstable_dev", () => {
19
19
  }
20
20
  await worker.stop();
21
21
  });
22
+
23
+ it("should return the port that the server started on (1)", async () => {
24
+ const worker = await unstable_dev(
25
+ "src/__tests__/helpers/worker-scripts/hello-world-worker.js",
26
+ {},
27
+ { disableExperimentalWarning: true }
28
+ );
29
+ expect(worker.port).toBeGreaterThan(0);
30
+ await worker.stop();
31
+ });
32
+
33
+ it("should return the port that the server started on (2)", async () => {
34
+ const worker = await unstable_dev(
35
+ "src/__tests__/helpers/worker-scripts/hello-world-worker.js",
36
+ { port: 9191 },
37
+ { disableExperimentalWarning: true }
38
+ );
39
+ expect(worker.port).toBe(9191);
40
+ await worker.stop();
41
+ });
22
42
  });
23
43
 
24
44
  describe("unstable dev fetch input protocol", () => {
@@ -25,6 +25,7 @@ describe("normalizeAndValidateConfig()", () => {
25
25
  compatibility_date: undefined,
26
26
  compatibility_flags: [],
27
27
  configPath: undefined,
28
+ d1_databases: [],
28
29
  dev: {
29
30
  ip: "0.0.0.0",
30
31
  local_protocol: "http",
@@ -1664,6 +1665,108 @@ describe("normalizeAndValidateConfig()", () => {
1664
1665
  });
1665
1666
  });
1666
1667
 
1668
+ describe("[d1_databases]", () => {
1669
+ it("should error if d1_databases is an object", () => {
1670
+ const { config, diagnostics } = normalizeAndValidateConfig(
1671
+ { d1_databases: {} } as unknown as RawConfig,
1672
+ undefined,
1673
+ { env: undefined }
1674
+ );
1675
+
1676
+ expect(config).toEqual(
1677
+ expect.not.objectContaining({ d1_databases: expect.anything })
1678
+ );
1679
+ expect(diagnostics.hasWarnings()).toBe(false);
1680
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1681
+ "Processing wrangler configuration:
1682
+ - The field \\"d1_databases\\" should be an array but got {}."
1683
+ `);
1684
+ });
1685
+
1686
+ it("should error if d1_databases is a string", () => {
1687
+ const { config, diagnostics } = normalizeAndValidateConfig(
1688
+ { d1_databases: "BAD" } as unknown as RawConfig,
1689
+ undefined,
1690
+ { env: undefined }
1691
+ );
1692
+
1693
+ expect(config).toEqual(
1694
+ expect.not.objectContaining({ d1_databases: expect.anything })
1695
+ );
1696
+ expect(diagnostics.hasWarnings()).toBe(false);
1697
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1698
+ "Processing wrangler configuration:
1699
+ - The field \\"d1_databases\\" should be an array but got \\"BAD\\"."
1700
+ `);
1701
+ });
1702
+
1703
+ it("should error if d1_databases is a number", () => {
1704
+ const { config, diagnostics } = normalizeAndValidateConfig(
1705
+ { d1_databases: 999 } as unknown as RawConfig,
1706
+ undefined,
1707
+ { env: undefined }
1708
+ );
1709
+
1710
+ expect(config).toEqual(
1711
+ expect.not.objectContaining({ d1_databases: expect.anything })
1712
+ );
1713
+ expect(diagnostics.hasWarnings()).toBe(false);
1714
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1715
+ "Processing wrangler configuration:
1716
+ - The field \\"d1_databases\\" should be an array but got 999."
1717
+ `);
1718
+ });
1719
+
1720
+ it("should error if d1_databases is null", () => {
1721
+ const { config, diagnostics } = normalizeAndValidateConfig(
1722
+ { d1_databases: null } as unknown as RawConfig,
1723
+ undefined,
1724
+ { env: undefined }
1725
+ );
1726
+
1727
+ expect(config).toEqual(
1728
+ expect.not.objectContaining({ d1_databases: expect.anything })
1729
+ );
1730
+ expect(diagnostics.hasWarnings()).toBe(false);
1731
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1732
+ "Processing wrangler configuration:
1733
+ - The field \\"d1_databases\\" should be an array but got null."
1734
+ `);
1735
+ });
1736
+
1737
+ it("should error if d1_databases.bindings are not valid", () => {
1738
+ const { diagnostics } = normalizeAndValidateConfig(
1739
+ {
1740
+ d1_databases: [
1741
+ {},
1742
+ { binding: "VALID" },
1743
+ { binding: 2000, id: 2111 },
1744
+ {
1745
+ binding: "D1_BINDING_2",
1746
+ id: "my-db",
1747
+ preview_id: 2222,
1748
+ },
1749
+ { binding: "VALID", id: "" },
1750
+ ],
1751
+ } as unknown as RawConfig,
1752
+ undefined,
1753
+ { env: undefined }
1754
+ );
1755
+
1756
+ expect(diagnostics.hasWarnings()).toBe(false);
1757
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1758
+ "Processing wrangler configuration:
1759
+ - \\"d1_databases[0]\\" bindings should have a string \\"binding\\" field but got {}.
1760
+ - \\"d1_databases[0]\\" bindings must have a \\"database_id\\" field but got {}.
1761
+ - \\"d1_databases[1]\\" bindings must have a \\"database_id\\" field but got {\\"binding\\":\\"VALID\\"}.
1762
+ - \\"d1_databases[2]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":2000,\\"id\\":2111}.
1763
+ - \\"d1_databases[2]\\" bindings must have a \\"database_id\\" field but got {\\"binding\\":2000,\\"id\\":2111}.
1764
+ - \\"d1_databases[3]\\" bindings must have a \\"database_id\\" field but got {\\"binding\\":\\"D1_BINDING_2\\",\\"id\\":\\"my-db\\",\\"preview_id\\":2222}.
1765
+ - \\"d1_databases[4]\\" bindings must have a \\"database_id\\" field but got {\\"binding\\":\\"VALID\\",\\"id\\":\\"\\"}."
1766
+ `);
1767
+ });
1768
+ });
1769
+
1667
1770
  describe("[r2_buckets]", () => {
1668
1771
  it("should error if r2_buckets is an object", () => {
1669
1772
  const { config, diagnostics } = normalizeAndValidateConfig(
@@ -2664,28 +2767,28 @@ describe("normalizeAndValidateConfig()", () => {
2664
2767
  );
2665
2768
  expect(diagnostics.hasErrors()).toBe(false);
2666
2769
  expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
2667
- "Processing wrangler configuration:
2668
- - \\"unsafe\\" fields are experimental and may change or break at any time.
2669
- - \\"env.ENV1\\" environment configuration
2670
- - \\"vars\\" exists at the top level, but not on \\"env.ENV1\\".
2671
- This is not what you probably want, since \\"vars\\" is not inherited by environments.
2672
- Please add \\"vars\\" to \\"env.ENV1\\".
2673
- - \\"define\\" exists at the top level, but not on \\"env.ENV1\\".
2674
- This is not what you probably want, since \\"define\\" is not inherited by environments.
2675
- Please add \\"define\\" to \\"env.ENV1\\".
2676
- - \\"durable_objects\\" exists at the top level, but not on \\"env.ENV1\\".
2677
- This is not what you probably want, since \\"durable_objects\\" is not inherited by environments.
2678
- Please add \\"durable_objects\\" to \\"env.ENV1\\".
2679
- - \\"kv_namespaces\\" exists at the top level, but not on \\"env.ENV1\\".
2680
- This is not what you probably want, since \\"kv_namespaces\\" is not inherited by environments.
2681
- Please add \\"kv_namespaces\\" to \\"env.ENV1\\".
2682
- - \\"r2_buckets\\" exists at the top level, but not on \\"env.ENV1\\".
2683
- This is not what you probably want, since \\"r2_buckets\\" is not inherited by environments.
2684
- Please add \\"r2_buckets\\" to \\"env.ENV1\\".
2685
- - \\"unsafe\\" exists at the top level, but not on \\"env.ENV1\\".
2686
- This is not what you probably want, since \\"unsafe\\" is not inherited by environments.
2687
- Please add \\"unsafe\\" to \\"env.ENV1\\"."
2688
- `);
2770
+ "Processing wrangler configuration:
2771
+ - \\"unsafe\\" fields are experimental and may change or break at any time.
2772
+ - \\"env.ENV1\\" environment configuration
2773
+ - \\"vars\\" exists at the top level, but not on \\"env.ENV1\\".
2774
+ This is not what you probably want, since \\"vars\\" is not inherited by environments.
2775
+ Please add \\"vars\\" to \\"env.ENV1\\".
2776
+ - \\"define\\" exists at the top level, but not on \\"env.ENV1\\".
2777
+ This is not what you probably want, since \\"define\\" is not inherited by environments.
2778
+ Please add \\"define\\" to \\"env.ENV1\\".
2779
+ - \\"durable_objects\\" exists at the top level, but not on \\"env.ENV1\\".
2780
+ This is not what you probably want, since \\"durable_objects\\" is not inherited by environments.
2781
+ Please add \\"durable_objects\\" to \\"env.ENV1\\".
2782
+ - \\"kv_namespaces\\" exists at the top level, but not on \\"env.ENV1\\".
2783
+ This is not what you probably want, since \\"kv_namespaces\\" is not inherited by environments.
2784
+ Please add \\"kv_namespaces\\" to \\"env.ENV1\\".
2785
+ - \\"r2_buckets\\" exists at the top level, but not on \\"env.ENV1\\".
2786
+ This is not what you probably want, since \\"r2_buckets\\" is not inherited by environments.
2787
+ Please add \\"r2_buckets\\" to \\"env.ENV1\\".
2788
+ - \\"unsafe\\" exists at the top level, but not on \\"env.ENV1\\".
2789
+ This is not what you probably want, since \\"unsafe\\" is not inherited by environments.
2790
+ Please add \\"unsafe\\" to \\"env.ENV1\\"."
2791
+ `);
2689
2792
  });
2690
2793
 
2691
2794
  it("should error on invalid environment values", () => {
@@ -183,7 +183,6 @@ describe("wrangler dev", () => {
183
183
  );
184
184
  });
185
185
  });
186
-
187
186
  describe("host", () => {
188
187
  it("should resolve a host to its zone", async () => {
189
188
  writeWranglerToml({
@@ -1108,7 +1107,6 @@ describe("wrangler dev", () => {
1108
1107
  await runWrangler("dev --assets abc");
1109
1108
  expect((Dev as jest.Mock).mock.calls[2][0].isWorkersSite).toEqual(false);
1110
1109
  });
1111
-
1112
1110
  it("should warn if --assets is used", async () => {
1113
1111
  writeWranglerToml({
1114
1112
  main: "./index.js",
@@ -97,7 +97,8 @@ export const mockOAuthFlow = () => {
97
97
  };
98
98
 
99
99
  fetchMock.mockIf(outcome.expected.url, async (req) => {
100
- outcome.actual = req;
100
+ // TODO: update Miniflare typings to match full undici Request
101
+ outcome.actual = req as unknown as Request;
101
102
  return "";
102
103
  });
103
104
 
@@ -117,7 +118,8 @@ export const mockOAuthFlow = () => {
117
118
  };
118
119
 
119
120
  fetchMock.mockOnceIf(outcome.expected.url, async (req) => {
120
- outcome.actual = req;
121
+ // TODO: update Miniflare typings to match full undici Request
122
+ outcome.actual = req as unknown as Request;
121
123
  return makeTokenResponse(respondWith);
122
124
  });
123
125
 
@@ -43,6 +43,7 @@ describe("wrangler", () => {
43
43
  wrangler pages ⚡️ Configure Cloudflare Pages
44
44
  wrangler r2 📦 Interact with an R2 store
45
45
  wrangler dispatch-namespace 📦 Interact with a dispatch namespace
46
+ wrangler d1 🗄 Interact with a D1 database
46
47
  wrangler pubsub 📮 Interact and manage Pub/Sub Brokers
47
48
  wrangler login 🔓 Login to Cloudflare
48
49
  wrangler logout 🚪 Logout from Cloudflare
@@ -83,6 +84,7 @@ describe("wrangler", () => {
83
84
  wrangler pages ⚡️ Configure Cloudflare Pages
84
85
  wrangler r2 📦 Interact with an R2 store
85
86
  wrangler dispatch-namespace 📦 Interact with a dispatch namespace
87
+ wrangler d1 🗄 Interact with a D1 database
86
88
  wrangler pubsub 📮 Interact and manage Pub/Sub Brokers
87
89
  wrangler login 🔓 Login to Cloudflare
88
90
  wrangler logout 🚪 Logout from Cloudflare
@@ -1,5 +1,5 @@
1
1
  import * as path from "node:path";
2
- import { getBasePath } from "../paths";
2
+ import { getBasePath, readableRelative } from "../paths";
3
3
 
4
4
  describe("paths", () => {
5
5
  describe("getBasePath()", () => {
@@ -15,3 +15,25 @@ describe("paths", () => {
15
15
  });
16
16
  });
17
17
  });
18
+
19
+ describe("readableRelative", () => {
20
+ const base = process.cwd();
21
+
22
+ it("should leave paths to files in the current directory as-is", () => {
23
+ expect(readableRelative(path.join(base, "wrangler.toml"))).toBe(
24
+ `wrangler.toml`
25
+ );
26
+ });
27
+
28
+ it("should leave files in the parent directory as-is", () => {
29
+ expect(readableRelative(path.resolve(base, "../wrangler.toml"))).toMatch(
30
+ /^\..[/\\]wrangler.toml$/
31
+ );
32
+ });
33
+
34
+ it("should add ./ to nested paths", () => {
35
+ expect(
36
+ readableRelative(path.join(base, "subdir", "wrangler.toml"))
37
+ ).toMatch(/^\.[/\\]subdir[/\\]wrangler\.toml$/);
38
+ });
39
+ });
@@ -123,14 +123,14 @@ describe("publish", () => {
123
123
  );
124
124
 
125
125
  expect(std.out).toMatchInlineSnapshot(`
126
- "Attempting to login via OAuth...
127
- Opening a link in your default browser: https://dash.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20pages%3Awrite%20zone%3Aread%20offline_access&state=MOCK_STATE_PARAM&code_challenge=MOCK_CODE_CHALLENGE&code_challenge_method=S256
128
- Successfully logged in.
129
- Total Upload: xx KiB / gzip: xx KiB
130
- Uploaded test-name (TIMINGS)
131
- Published test-name (TIMINGS)
132
- https://test-name.test-sub-domain.workers.dev"
133
- `);
126
+ "Attempting to login via OAuth...
127
+ Opening a link in your default browser: https://dash.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20d1%3Awrite%20pages%3Awrite%20zone%3Aread%20offline_access&state=MOCK_STATE_PARAM&code_challenge=MOCK_CODE_CHALLENGE&code_challenge_method=S256
128
+ Successfully logged in.
129
+ Total Upload: xx KiB / gzip: xx KiB
130
+ Uploaded test-name (TIMINGS)
131
+ Published test-name (TIMINGS)
132
+ https://test-name.test-sub-domain.workers.dev"
133
+ `);
134
134
  expect(std.warn).toMatchInlineSnapshot(`""`);
135
135
  expect(std.err).toMatchInlineSnapshot(`""`);
136
136
  });
@@ -559,7 +559,6 @@ describe("publish", () => {
559
559
  }
560
560
  `);
561
561
  });
562
-
563
562
  it("should publish to a route with a pattern/{zone_id|zone_name} combo", async () => {
564
563
  writeWranglerToml({
565
564
  routes: [
@@ -3669,7 +3668,6 @@ addEventListener('fetch', event => {});`
3669
3668
  );
3670
3669
  });
3671
3670
  });
3672
-
3673
3671
  describe("custom builds", () => {
3674
3672
  beforeEach(() => {
3675
3673
  // @ts-expect-error disable the mock we'd setup earlier
@@ -52,10 +52,10 @@ describe("User", () => {
52
52
  );
53
53
 
54
54
  expect(std.out).toMatchInlineSnapshot(`
55
- "Attempting to login via OAuth...
56
- Opening a link in your default browser: https://dash.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20pages%3Awrite%20zone%3Aread%20offline_access&state=MOCK_STATE_PARAM&code_challenge=MOCK_CODE_CHALLENGE&code_challenge_method=S256
57
- Successfully logged in."
58
- `);
55
+ "Attempting to login via OAuth...
56
+ Opening a link in your default browser: https://dash.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20d1%3Awrite%20pages%3Awrite%20zone%3Aread%20offline_access&state=MOCK_STATE_PARAM&code_challenge=MOCK_CODE_CHALLENGE&code_challenge_method=S256
57
+ Successfully logged in."
58
+ `);
59
59
 
60
60
  expect(readAuthConfigFile()).toEqual<UserAuthConfig>({
61
61
  api_token: undefined,
@@ -83,7 +83,6 @@ describe("getUserInfo()", () => {
83
83
  const userInfo = await getUserInfo();
84
84
  expect(userInfo?.email).toBeUndefined();
85
85
  });
86
-
87
86
  it("should say it's using an API token when one is set", async () => {
88
87
  process.env = {
89
88
  CLOUDFLARE_API_TOKEN: "123456789",