wrangler 2.4.3 → 2.5.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/bin/wrangler.js +20 -8
- package/miniflare-dist/index.mjs +8 -3
- package/package.json +1 -1
- package/src/__tests__/delete.test.ts +81 -48
- package/src/__tests__/dev.test.tsx +8 -8
- package/src/__tests__/helpers/mock-oauth-flow.ts +5 -1
- package/src/__tests__/helpers/msw/handlers/oauth.ts +13 -18
- package/src/__tests__/logout.test.ts +47 -0
- package/src/__tests__/queues.test.ts +155 -67
- package/src/__tests__/tail.test.ts +207 -108
- package/src/__tests__/user.test.ts +43 -69
- package/src/d1/backups.tsx +7 -2
- package/src/d1/delete.tsx +4 -4
- package/src/d1/index.ts +2 -0
- package/src/d1/migrations/apply.tsx +6 -5
- package/src/d1/migrations/helpers.ts +4 -2
- package/src/d1/migrations/list.tsx +2 -2
- package/src/d1/migrations/options.ts +18 -0
- package/src/dev/dev.tsx +46 -22
- package/src/dev/local.tsx +18 -14
- package/src/dev/start-server.ts +22 -21
- package/src/dev.tsx +10 -11
- package/src/miniflare-cli/assets.ts +7 -2
- package/src/miniflare-cli/index.ts +1 -1
- package/src/pages/dev.tsx +0 -2
- package/src/proxy.ts +5 -0
- package/wrangler-dist/cli.js +221 -178
package/src/dev/start-server.ts
CHANGED
|
@@ -112,8 +112,8 @@ export async function startDevServer(
|
|
|
112
112
|
compatibilityFlags: props.compatibilityFlags,
|
|
113
113
|
bindings: props.bindings,
|
|
114
114
|
assetPaths: props.assetPaths,
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
initialPort: props.initialPort,
|
|
116
|
+
initialIp: props.initialIp,
|
|
117
117
|
rules: props.rules,
|
|
118
118
|
inspectorPort: props.inspectorPort,
|
|
119
119
|
localPersistencePath: props.localPersistencePath,
|
|
@@ -149,8 +149,8 @@ export async function startDevServer(
|
|
|
149
149
|
bindings: props.bindings,
|
|
150
150
|
assetPaths: props.assetPaths,
|
|
151
151
|
isWorkersSite: props.isWorkersSite,
|
|
152
|
-
port: props.
|
|
153
|
-
ip: props.
|
|
152
|
+
port: props.initialPort,
|
|
153
|
+
ip: props.initialIp,
|
|
154
154
|
localProtocol: props.localProtocol,
|
|
155
155
|
inspectorPort: props.inspectorPort,
|
|
156
156
|
inspect: props.inspect,
|
|
@@ -294,12 +294,12 @@ export async function startLocalServer({
|
|
|
294
294
|
bindings,
|
|
295
295
|
workerDefinitions,
|
|
296
296
|
assetPaths,
|
|
297
|
-
|
|
297
|
+
initialPort,
|
|
298
298
|
inspectorPort,
|
|
299
299
|
rules,
|
|
300
300
|
localPersistencePath,
|
|
301
301
|
liveReload,
|
|
302
|
-
|
|
302
|
+
initialIp,
|
|
303
303
|
crons,
|
|
304
304
|
queueConsumers,
|
|
305
305
|
localProtocol,
|
|
@@ -325,14 +325,11 @@ export async function startLocalServer({
|
|
|
325
325
|
if (!bundle || !format) return;
|
|
326
326
|
|
|
327
327
|
// port for the worker
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
abortSignal: abortController.signal,
|
|
334
|
-
});
|
|
335
|
-
}
|
|
328
|
+
await waitForPortToBeAvailable(initialPort, {
|
|
329
|
+
retryPeriod: 200,
|
|
330
|
+
timeout: 2000,
|
|
331
|
+
abortSignal: abortController.signal,
|
|
332
|
+
});
|
|
336
333
|
|
|
337
334
|
if (bindings.services && bindings.services.length > 0) {
|
|
338
335
|
logger.warn(
|
|
@@ -373,10 +370,10 @@ export async function startLocalServer({
|
|
|
373
370
|
|
|
374
371
|
const { forkOptions, miniflareCLIPath, options } = setupMiniflareOptions({
|
|
375
372
|
workerName,
|
|
376
|
-
port,
|
|
373
|
+
port: initialPort,
|
|
377
374
|
scriptPath,
|
|
378
375
|
localProtocol,
|
|
379
|
-
ip,
|
|
376
|
+
ip: initialIp,
|
|
380
377
|
format,
|
|
381
378
|
rules,
|
|
382
379
|
compatibilityDate,
|
|
@@ -429,7 +426,11 @@ export async function startLocalServer({
|
|
|
429
426
|
return;
|
|
430
427
|
}
|
|
431
428
|
|
|
432
|
-
const nodeOptions = setupNodeOptions({
|
|
429
|
+
const nodeOptions = setupNodeOptions({
|
|
430
|
+
inspect,
|
|
431
|
+
ip: initialIp,
|
|
432
|
+
inspectorPort,
|
|
433
|
+
});
|
|
433
434
|
logger.log("⎔ Starting a local server...");
|
|
434
435
|
|
|
435
436
|
const child = (local = fork(miniflareCLIPath, forkOptions, {
|
|
@@ -446,21 +447,21 @@ export async function startLocalServer({
|
|
|
446
447
|
await registerWorker(workerName, {
|
|
447
448
|
protocol: localProtocol,
|
|
448
449
|
mode: "local",
|
|
449
|
-
port: message.
|
|
450
|
-
host:
|
|
450
|
+
port: message.port,
|
|
451
|
+
host: initialIp,
|
|
451
452
|
durableObjects: internalDurableObjects.map((binding) => ({
|
|
452
453
|
name: binding.name,
|
|
453
454
|
className: binding.class_name,
|
|
454
455
|
})),
|
|
455
456
|
...(message.durableObjectsPort
|
|
456
457
|
? {
|
|
457
|
-
durableObjectsHost:
|
|
458
|
+
durableObjectsHost: initialIp,
|
|
458
459
|
durableObjectsPort: message.durableObjectsPort,
|
|
459
460
|
}
|
|
460
461
|
: {}),
|
|
461
462
|
});
|
|
462
463
|
}
|
|
463
|
-
onReady?.(
|
|
464
|
+
onReady?.(initialIp, message.port);
|
|
464
465
|
}
|
|
465
466
|
});
|
|
466
467
|
|
package/src/dev.tsx
CHANGED
|
@@ -467,11 +467,13 @@ export async function startDev(args: StartDevOptions) {
|
|
|
467
467
|
accountId={configParam.account_id || getAccountFromCache()?.id}
|
|
468
468
|
assetPaths={assetPaths}
|
|
469
469
|
assetsConfig={configParam.assets}
|
|
470
|
-
|
|
471
|
-
|
|
470
|
+
initialPort={
|
|
471
|
+
args.port ?? configParam.dev.port ?? (await getLocalPort())
|
|
472
|
+
}
|
|
473
|
+
initialIp={args.ip || configParam.dev.ip}
|
|
472
474
|
inspectorPort={
|
|
473
|
-
args.inspectorPort
|
|
474
|
-
configParam.dev.inspector_port
|
|
475
|
+
args.inspectorPort ??
|
|
476
|
+
configParam.dev.inspector_port ??
|
|
475
477
|
(await getInspectorPort())
|
|
476
478
|
}
|
|
477
479
|
isWorkersSite={Boolean(args.site || configParam.site)}
|
|
@@ -584,14 +586,11 @@ export async function startApiDev(args: StartDevOptions) {
|
|
|
584
586
|
assetPaths: assetPaths,
|
|
585
587
|
assetsConfig: configParam.assets,
|
|
586
588
|
//port can be 0, which means to use a random port
|
|
587
|
-
port
|
|
588
|
-
|
|
589
|
-
? args.port
|
|
590
|
-
: args.port || configParam.dev.port || (await getLocalPort()),
|
|
591
|
-
ip: args.ip || configParam.dev.ip,
|
|
589
|
+
initialPort: args.port ?? configParam.dev.port ?? (await getLocalPort()),
|
|
590
|
+
initialIp: args.ip || configParam.dev.ip,
|
|
592
591
|
inspectorPort:
|
|
593
|
-
args["inspector-port"]
|
|
594
|
-
configParam.dev.inspector_port
|
|
592
|
+
args["inspector-port"] ??
|
|
593
|
+
configParam.dev.inspector_port ??
|
|
595
594
|
(await getInspectorPort()),
|
|
596
595
|
isWorkersSite: Boolean(args.site || configParam.site),
|
|
597
596
|
compatibilityDate: getDevCompatibilityDate(
|
|
@@ -3,11 +3,11 @@ import { join } from "node:path";
|
|
|
3
3
|
import { createMetadataObject } from "@cloudflare/pages-shared/metadata-generator/createMetadataObject";
|
|
4
4
|
import { parseHeaders } from "@cloudflare/pages-shared/metadata-generator/parseHeaders";
|
|
5
5
|
import { parseRedirects } from "@cloudflare/pages-shared/metadata-generator/parseRedirects";
|
|
6
|
-
import { fetch as miniflareFetch } from "@miniflare/core";
|
|
7
6
|
import {
|
|
8
7
|
Response as MiniflareResponse,
|
|
9
8
|
Request as MiniflareRequest,
|
|
10
9
|
} from "@miniflare/core";
|
|
10
|
+
import { upgradingFetch as miniflareFetch } from "@miniflare/web-sockets";
|
|
11
11
|
import { watch } from "chokidar";
|
|
12
12
|
import { getType } from "mime";
|
|
13
13
|
import { hashFile } from "../pages/hash";
|
|
@@ -40,7 +40,12 @@ export default async function generateASSETSBinding(options: Options) {
|
|
|
40
40
|
try {
|
|
41
41
|
const url = new URL(miniflareRequest.url);
|
|
42
42
|
url.host = `localhost:${options.proxyPort}`;
|
|
43
|
-
|
|
43
|
+
const proxyRequest = new MiniflareRequest(url, miniflareRequest);
|
|
44
|
+
if (proxyRequest.headers.get("Upgrade") === "websocket") {
|
|
45
|
+
proxyRequest.headers.delete("Sec-WebSocket-Accept");
|
|
46
|
+
proxyRequest.headers.delete("Sec-WebSocket-Key");
|
|
47
|
+
}
|
|
48
|
+
return await miniflareFetch(proxyRequest);
|
|
44
49
|
} catch (thrown) {
|
|
45
50
|
options.log.error(new Error(`Could not proxy request: ${thrown}`));
|
|
46
51
|
|
package/src/pages/dev.tsx
CHANGED
|
@@ -293,7 +293,6 @@ export const Handler = async ({
|
|
|
293
293
|
buildOutputDirectory: directory,
|
|
294
294
|
nodeCompat,
|
|
295
295
|
local: true,
|
|
296
|
-
d1Databases: d1s.map((binding) => binding.toString()),
|
|
297
296
|
});
|
|
298
297
|
await metrics.sendMetricsEvent("build pages functions");
|
|
299
298
|
|
|
@@ -312,7 +311,6 @@ export const Handler = async ({
|
|
|
312
311
|
buildOutputDirectory: directory,
|
|
313
312
|
nodeCompat,
|
|
314
313
|
local: true,
|
|
315
|
-
d1Databases: d1s.map((binding) => binding.toString()),
|
|
316
314
|
});
|
|
317
315
|
await metrics.sendMetricsEvent("build pages functions");
|
|
318
316
|
} catch (e) {
|
package/src/proxy.ts
CHANGED
|
@@ -651,6 +651,11 @@ export async function waitForPortToBeAvailable(
|
|
|
651
651
|
}
|
|
652
652
|
|
|
653
653
|
function checkPort() {
|
|
654
|
+
if (port === 0) {
|
|
655
|
+
doResolve();
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
|
|
654
659
|
// Testing whether a port is 'available' involves simply
|
|
655
660
|
// trying to make a server listen on that port, and retrying
|
|
656
661
|
// until it succeeds.
|