wrangler 0.0.0-e14e589 → 0.0.0-e151223

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 (55) hide show
  1. package/README.md +51 -0
  2. package/bin/wrangler.js +2 -2
  3. package/package.json +46 -29
  4. package/pages/functions/buildWorker.ts +62 -0
  5. package/pages/functions/filepath-routing.test.ts +47 -0
  6. package/pages/functions/filepath-routing.ts +231 -0
  7. package/pages/functions/identifiers.ts +78 -0
  8. package/pages/functions/routes.ts +160 -0
  9. package/pages/functions/template-worker.ts +136 -0
  10. package/src/__tests__/dev.test.tsx +71 -0
  11. package/src/__tests__/{clipboardy-mock.js → helpers/clipboardy-mock.js} +0 -0
  12. package/src/__tests__/helpers/mock-account-id.ts +30 -0
  13. package/src/__tests__/helpers/mock-cfetch.ts +173 -0
  14. package/src/__tests__/helpers/mock-console.ts +56 -0
  15. package/src/__tests__/helpers/mock-dialogs.ts +65 -0
  16. package/src/__tests__/helpers/mock-kv.ts +40 -0
  17. package/src/__tests__/helpers/mock-user.ts +27 -0
  18. package/src/__tests__/helpers/run-in-tmp.ts +29 -0
  19. package/src/__tests__/helpers/run-wrangler.ts +14 -0
  20. package/src/__tests__/index.test.ts +372 -119
  21. package/src/__tests__/jest.setup.ts +34 -0
  22. package/src/__tests__/kv.test.ts +1149 -0
  23. package/src/__tests__/logout.test.ts +50 -0
  24. package/src/__tests__/publish.test.ts +1222 -0
  25. package/src/__tests__/secret.test.ts +210 -0
  26. package/src/__tests__/whoami.test.tsx +86 -0
  27. package/src/api/form_data.ts +85 -76
  28. package/src/api/preview.ts +29 -24
  29. package/src/api/worker.ts +50 -35
  30. package/src/cfetch/index.ts +111 -0
  31. package/src/cfetch/internal.ts +72 -0
  32. package/src/cli.ts +6 -7
  33. package/src/config.ts +630 -85
  34. package/src/dev.tsx +446 -282
  35. package/src/dialogs.tsx +6 -14
  36. package/src/index.tsx +724 -418
  37. package/src/inspect.ts +596 -0
  38. package/src/kv.tsx +110 -45
  39. package/src/module-collection.ts +63 -0
  40. package/src/npm-installer.ts +20 -0
  41. package/src/pages.tsx +916 -211
  42. package/src/paths.ts +26 -0
  43. package/src/proxy.ts +370 -0
  44. package/src/publish.ts +219 -87
  45. package/src/sites.tsx +180 -55
  46. package/src/tail.tsx +6 -4
  47. package/src/user.tsx +77 -87
  48. package/src/whoami.tsx +69 -0
  49. package/wrangler-dist/cli.js +125169 -557
  50. package/wrangler-dist/cli.js.map +3 -3
  51. package/src/__tests__/fixtures/init/.gitkeep +0 -0
  52. package/src/__tests__/mock-cfetch.js +0 -46
  53. package/src/api/inspect.ts +0 -441
  54. package/src/cfetch.ts +0 -72
  55. package/src/util/fetch.ts +0 -74
@@ -0,0 +1,50 @@
1
+ import { existsSync } from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import fetchMock from "jest-fetch-mock";
5
+ import { initialise } from "../user";
6
+ import { mockConsoleMethods } from "./helpers/mock-console";
7
+ import { writeUserConfig } from "./helpers/mock-user";
8
+ import { runInTempDir } from "./helpers/run-in-tmp";
9
+ import { runWrangler } from "./helpers/run-wrangler";
10
+
11
+ describe("wrangler", () => {
12
+ runInTempDir({ homedir: "./home" });
13
+ const std = mockConsoleMethods();
14
+
15
+ describe("logout", () => {
16
+ it("should exit with a message stating the user is not logged in", async () => {
17
+ await initialise();
18
+ await runWrangler("logout");
19
+ expect(std.out).toMatchInlineSnapshot(`"Not logged in, exiting..."`);
20
+ });
21
+
22
+ it("should logout user that has been properly logged in", async () => {
23
+ writeUserConfig("some-oauth-tok", "some-refresh-tok");
24
+
25
+ // Mock out the response for a request to revoke the auth tokens,
26
+ // checking the form of the request is as expected.
27
+ fetchMock.mockResponseOnce(async (req) => {
28
+ expect(req.url).toEqual("https://dash.cloudflare.com/oauth2/revoke");
29
+ expect(req.method).toEqual("POST");
30
+ return "";
31
+ });
32
+
33
+ await initialise();
34
+ await runWrangler("logout");
35
+
36
+ expect(std.out).toMatchInlineSnapshot(`
37
+ "💁 Wrangler is configured with an OAuth token. The token has been successfully revoked
38
+ Removing ./home/.wrangler/config/default.toml.. success!"
39
+ `);
40
+
41
+ // Make sure that we made the request to logout.
42
+ expect(fetchMock).toHaveBeenCalledTimes(1);
43
+
44
+ // Make sure that logout removed the config file containing the auth tokens.
45
+ expect(
46
+ existsSync(path.join(os.homedir(), ".wrangler/config/default.toml"))
47
+ ).toBe(false);
48
+ });
49
+ });
50
+ });