wrangler 2.0.24 → 2.0.25
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/miniflare-dist/index.mjs +130 -16
- package/package.json +1 -1
- package/src/__tests__/configuration.test.ts +1 -1
- package/src/__tests__/dev.test.tsx +26 -4
- package/src/__tests__/helpers/mock-cfetch.ts +2 -2
- package/src/__tests__/r2.test.ts +18 -0
- package/src/__tests__/tail.test.ts +93 -39
- package/src/api/dev.ts +6 -0
- package/src/bundle.ts +3 -2
- package/src/config/config.ts +1 -1
- package/src/config/validation.ts +1 -1
- package/src/dev/dev.tsx +12 -2
- package/src/dev/local.tsx +69 -5
- package/src/dev/use-esbuild.ts +3 -0
- package/src/dev-registry.tsx +3 -0
- package/src/dev.tsx +26 -17
- package/src/index.tsx +51 -21
- package/src/inspect.ts +1 -4
- package/src/miniflare-cli/assets.ts +19 -16
- package/src/miniflare-cli/index.ts +121 -2
- package/src/pages/build.tsx +36 -28
- package/src/pages/constants.ts +3 -0
- package/src/pages/deployments.tsx +9 -9
- package/src/pages/dev.tsx +85 -27
- package/src/pages/functions/buildPlugin.ts +4 -0
- package/src/pages/functions/buildWorker.ts +4 -0
- package/src/pages/functions/routes-consolidation.test.ts +66 -0
- package/src/pages/functions/routes-consolidation.ts +29 -0
- package/src/pages/functions/routes-transformation.test.ts +271 -0
- package/src/pages/functions/routes-transformation.ts +125 -0
- package/src/pages/projects.tsx +9 -3
- package/src/pages/publish.tsx +56 -14
- package/src/pages/types.ts +9 -0
- package/src/pages/upload.tsx +6 -8
- package/src/r2.ts +13 -0
- package/src/tail/index.ts +15 -2
- package/src/tail/printing.ts +41 -3
- package/wrangler-dist/cli.d.ts +6 -0
- package/wrangler-dist/cli.js +385 -89
package/src/tail/printing.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { logger } from "../logger";
|
|
2
|
-
import type { RequestEvent, ScheduledEvent, TailEventMessage } from ".";
|
|
3
2
|
import type { Outcome } from "./filters";
|
|
3
|
+
import type {
|
|
4
|
+
AlarmEvent,
|
|
5
|
+
RequestEvent,
|
|
6
|
+
ScheduledEvent,
|
|
7
|
+
TailEventMessage,
|
|
8
|
+
} from "./index";
|
|
4
9
|
import type WebSocket from "ws";
|
|
5
10
|
|
|
6
11
|
export function prettyPrintLogs(data: WebSocket.RawData): void {
|
|
@@ -14,7 +19,7 @@ export function prettyPrintLogs(data: WebSocket.RawData): void {
|
|
|
14
19
|
const outcome = prettifyOutcome(eventMessage.outcome);
|
|
15
20
|
|
|
16
21
|
logger.log(`"${cronPattern}" @ ${datetime} - ${outcome}`);
|
|
17
|
-
} else {
|
|
22
|
+
} else if (isRequestEvent(eventMessage.event)) {
|
|
18
23
|
const requestMethod = eventMessage.event?.request.method.toUpperCase();
|
|
19
24
|
const url = eventMessage.event?.request.url;
|
|
20
25
|
const outcome = prettifyOutcome(eventMessage.outcome);
|
|
@@ -25,6 +30,19 @@ export function prettyPrintLogs(data: WebSocket.RawData): void {
|
|
|
25
30
|
? `${requestMethod} ${url} - ${outcome} @ ${datetime}`
|
|
26
31
|
: `[missing request] - ${outcome} @ ${datetime}`
|
|
27
32
|
);
|
|
33
|
+
} else if (isAlarmEvent(eventMessage.event)) {
|
|
34
|
+
const outcome = prettifyOutcome(eventMessage.outcome);
|
|
35
|
+
const datetime = new Date(
|
|
36
|
+
eventMessage.event.scheduledTime
|
|
37
|
+
).toLocaleString();
|
|
38
|
+
|
|
39
|
+
logger.log(`Alarm @ ${datetime} - ${outcome}`);
|
|
40
|
+
} else {
|
|
41
|
+
// Unknown event type
|
|
42
|
+
const outcome = prettifyOutcome(eventMessage.outcome);
|
|
43
|
+
const datetime = new Date(eventMessage.eventTimestamp).toLocaleString();
|
|
44
|
+
|
|
45
|
+
logger.log(`Unknown Event - ${outcome} @ ${datetime}`);
|
|
28
46
|
}
|
|
29
47
|
|
|
30
48
|
if (eventMessage.logs.length > 0) {
|
|
@@ -44,12 +62,32 @@ export function jsonPrintLogs(data: WebSocket.RawData): void {
|
|
|
44
62
|
console.log(JSON.stringify(JSON.parse(data.toString()), null, 2));
|
|
45
63
|
}
|
|
46
64
|
|
|
65
|
+
function isRequestEvent(
|
|
66
|
+
event: TailEventMessage["event"]
|
|
67
|
+
): event is RequestEvent {
|
|
68
|
+
return Boolean(event && "request" in event);
|
|
69
|
+
}
|
|
70
|
+
|
|
47
71
|
function isScheduledEvent(
|
|
48
|
-
event:
|
|
72
|
+
event: TailEventMessage["event"]
|
|
49
73
|
): event is ScheduledEvent {
|
|
50
74
|
return Boolean(event && "cron" in event);
|
|
51
75
|
}
|
|
52
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Check to see if an event sent from a worker is an AlarmEvent.
|
|
79
|
+
*
|
|
80
|
+
* Because the only property on `AlarmEvent` is "scheduledTime", which it
|
|
81
|
+
* shares with `ScheduledEvent`, `isAlarmEvent` checks if there's _not_
|
|
82
|
+
* a "cron" property in `event` to confirm it's an alarm event.
|
|
83
|
+
*
|
|
84
|
+
* @param event An event
|
|
85
|
+
* @returns true if the event is an AlarmEvent
|
|
86
|
+
*/
|
|
87
|
+
function isAlarmEvent(event: TailEventMessage["event"]): event is AlarmEvent {
|
|
88
|
+
return Boolean(event && "scheduledTime" in event && !("cron" in event));
|
|
89
|
+
}
|
|
90
|
+
|
|
53
91
|
function prettifyOutcome(outcome: Outcome): string {
|
|
54
92
|
switch (outcome) {
|
|
55
93
|
case "ok":
|
package/wrangler-dist/cli.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ declare interface DevOptions {
|
|
|
33
33
|
env?: string;
|
|
34
34
|
ip?: string;
|
|
35
35
|
port?: number;
|
|
36
|
+
inspectorPort?: number;
|
|
36
37
|
localProtocol?: "http" | "https";
|
|
37
38
|
assets?: string;
|
|
38
39
|
site?: string;
|
|
@@ -57,6 +58,11 @@ declare interface DevOptions {
|
|
|
57
58
|
script_name?: string | undefined;
|
|
58
59
|
environment?: string | undefined;
|
|
59
60
|
}[];
|
|
61
|
+
r2?: {
|
|
62
|
+
binding: string;
|
|
63
|
+
bucket_name: string;
|
|
64
|
+
preview_bucket_name?: string;
|
|
65
|
+
}[];
|
|
60
66
|
showInteractiveDevSession?: boolean;
|
|
61
67
|
logLevel?: "none" | "error" | "log" | "warn" | "debug";
|
|
62
68
|
logPrefix?: string;
|