wrangler 2.7.0 → 2.8.0
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/package.json +1 -1
- package/src/__tests__/helpers/mock-dialogs.ts +2 -0
- package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -5
- package/src/__tests__/helpers/mock-known-routes.ts +7 -2
- package/src/__tests__/helpers/mock-kv.ts +29 -16
- package/src/__tests__/helpers/mock-oauth-flow.ts +90 -98
- package/src/__tests__/helpers/msw/handlers/deployments.ts +18 -0
- package/src/__tests__/helpers/msw/index.ts +30 -1
- package/src/__tests__/init.test.ts +3 -14
- package/src/__tests__/jest.setup.ts +0 -23
- package/src/__tests__/pages-deployment-tail.test.ts +72 -1
- package/src/__tests__/pages.test.ts +18 -16
- package/src/__tests__/publish.test.ts +744 -522
- package/src/__tests__/secret.test.ts +1 -9
- package/src/__tests__/tail.test.ts +66 -1
- package/src/__tests__/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/user.test.ts +5 -15
- package/src/api/dev.ts +17 -5
- package/src/cfetch/internal.ts +0 -3
- package/src/d1/backups.tsx +1 -5
- package/src/dev/remote.tsx +2 -0
- package/src/docs/index.ts +2 -1
- package/src/init.ts +1 -1
- package/src/pages/dev.ts +57 -62
- package/src/pages/functions/buildPlugin.ts +2 -20
- package/src/pages/functions/buildWorker.ts +136 -20
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
- package/src/pages/publish.tsx +36 -9
- package/src/publish/publish.ts +29 -4
- package/src/tail/createTail.ts +28 -1
- package/src/tail/printing.ts +15 -0
- package/templates/checked-fetch.js +1 -3
- package/wrangler-dist/cli.js +2935 -2824
- package/src/__tests__/helpers/mock-cfetch.ts +0 -278
|
@@ -6,7 +6,7 @@ import { mockAccountId, mockApiToken } from "./helpers/mock-account-id";
|
|
|
6
6
|
import { mockConsoleMethods } from "./helpers/mock-console";
|
|
7
7
|
import { mockConfirm, mockPrompt, clearDialogs } from "./helpers/mock-dialogs";
|
|
8
8
|
import { useMockIsTTY } from "./helpers/mock-istty";
|
|
9
|
-
|
|
9
|
+
import { mockGetMembershipsFail } from "./helpers/mock-oauth-flow";
|
|
10
10
|
import { useMockStdin } from "./helpers/mock-stdin";
|
|
11
11
|
import { msw } from "./helpers/msw";
|
|
12
12
|
import { runInTempDir } from "./helpers/run-in-tmp";
|
|
@@ -21,14 +21,6 @@ function createFetchResult(result: unknown, success = true) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export function mockGetMembershipsFail() {
|
|
25
|
-
msw.use(
|
|
26
|
-
rest.get("*/memberships", (req, res, ctx) => {
|
|
27
|
-
return res.once(ctx.json(createFetchResult([], false)));
|
|
28
|
-
})
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
24
|
export function mockGetMemberships(
|
|
33
25
|
accounts: { id: string; account: { id: string; name: string } }[]
|
|
34
26
|
) {
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
RequestEvent,
|
|
14
14
|
ScheduledEvent,
|
|
15
15
|
AlarmEvent,
|
|
16
|
+
EmailEvent,
|
|
16
17
|
} from "../tail/createTail";
|
|
17
18
|
import type { RequestInit } from "undici";
|
|
18
19
|
import type WebSocket from "ws";
|
|
@@ -404,6 +405,18 @@ describe("tail", () => {
|
|
|
404
405
|
expect(std.out).toMatch(deserializeToJson(serializedMessage));
|
|
405
406
|
});
|
|
406
407
|
|
|
408
|
+
it("logs email messages in json format", async () => {
|
|
409
|
+
const api = mockWebsocketAPIs();
|
|
410
|
+
await runWrangler("tail test-worker --format json");
|
|
411
|
+
|
|
412
|
+
const event = generateMockEmailEvent();
|
|
413
|
+
const message = generateMockEventMessage({ event });
|
|
414
|
+
const serializedMessage = serialize(message);
|
|
415
|
+
|
|
416
|
+
api.ws.send(serializedMessage);
|
|
417
|
+
expect(std.out).toMatch(deserializeToJson(serializedMessage));
|
|
418
|
+
});
|
|
419
|
+
|
|
407
420
|
it("logs request messages in pretty format", async () => {
|
|
408
421
|
const api = mockWebsocketAPIs();
|
|
409
422
|
await runWrangler("tail test-worker --format pretty");
|
|
@@ -473,6 +486,29 @@ describe("tail", () => {
|
|
|
473
486
|
`);
|
|
474
487
|
});
|
|
475
488
|
|
|
489
|
+
it("logs email messages in pretty format", async () => {
|
|
490
|
+
const api = mockWebsocketAPIs();
|
|
491
|
+
await runWrangler("tail test-worker --format pretty");
|
|
492
|
+
|
|
493
|
+
const event = generateMockEmailEvent();
|
|
494
|
+
const message = generateMockEventMessage({ event });
|
|
495
|
+
const serializedMessage = serialize(message);
|
|
496
|
+
|
|
497
|
+
api.ws.send(serializedMessage);
|
|
498
|
+
expect(
|
|
499
|
+
std.out
|
|
500
|
+
.replace(
|
|
501
|
+
new Date(mockEventTimestamp).toLocaleString(),
|
|
502
|
+
"[mock event timestamp]"
|
|
503
|
+
)
|
|
504
|
+
.replace(mockTailExpiration.toISOString(), "[mock expiration date]")
|
|
505
|
+
).toMatchInlineSnapshot(`
|
|
506
|
+
"Successfully created tail, expires at [mock expiration date]
|
|
507
|
+
Connected to test-worker, waiting for logs...
|
|
508
|
+
Email from:${mockEmailEventFrom} to:${mockEmailEventTo} size:${mockEmailEventSize} @ [mock event timestamp] - Ok"
|
|
509
|
+
`);
|
|
510
|
+
});
|
|
511
|
+
|
|
476
512
|
it("should not crash when the tail message has a void event", async () => {
|
|
477
513
|
const api = mockWebsocketAPIs();
|
|
478
514
|
await runWrangler("tail test-worker --format pretty");
|
|
@@ -634,7 +670,13 @@ function serialize(message: TailEventMessage): WebSocket.RawData {
|
|
|
634
670
|
* @returns true if `event` is a RequestEvent
|
|
635
671
|
*/
|
|
636
672
|
function isRequest(
|
|
637
|
-
event:
|
|
673
|
+
event:
|
|
674
|
+
| ScheduledEvent
|
|
675
|
+
| RequestEvent
|
|
676
|
+
| AlarmEvent
|
|
677
|
+
| EmailEvent
|
|
678
|
+
| undefined
|
|
679
|
+
| null
|
|
638
680
|
): event is RequestEvent {
|
|
639
681
|
return Boolean(event && "request" in event);
|
|
640
682
|
}
|
|
@@ -735,6 +777,21 @@ const mockEventTimestamp = 1645454470467;
|
|
|
735
777
|
*/
|
|
736
778
|
const mockEventScheduledTime = new Date(mockEventTimestamp).toISOString();
|
|
737
779
|
|
|
780
|
+
/**
|
|
781
|
+
* Default value for email event from
|
|
782
|
+
*/
|
|
783
|
+
const mockEmailEventFrom = "from@example.com";
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Default value for email event to
|
|
787
|
+
*/
|
|
788
|
+
const mockEmailEventTo = "to@example.com";
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Default value for email event mail size
|
|
792
|
+
*/
|
|
793
|
+
const mockEmailEventSize = 45416;
|
|
794
|
+
|
|
738
795
|
/**
|
|
739
796
|
* Mock out the API hit during Tail deletion
|
|
740
797
|
*
|
|
@@ -903,3 +960,11 @@ function generateMockAlarmEvent(opts?: Partial<AlarmEvent>): AlarmEvent {
|
|
|
903
960
|
scheduledTime: opts?.scheduledTime || mockEventScheduledTime,
|
|
904
961
|
};
|
|
905
962
|
}
|
|
963
|
+
|
|
964
|
+
function generateMockEmailEvent(opts?: Partial<EmailEvent>): EmailEvent {
|
|
965
|
+
return {
|
|
966
|
+
mailFrom: opts?.mailFrom || mockEmailEventFrom,
|
|
967
|
+
rcptTo: opts?.rcptTo || mockEmailEventTo,
|
|
968
|
+
rawSize: opts?.rawSize || mockEmailEventSize,
|
|
969
|
+
};
|
|
970
|
+
}
|