wrangler 2.0.22 → 2.0.23
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 +464 -4
- package/package.json +10 -3
- package/src/__tests__/dev.test.tsx +92 -4
- package/src/__tests__/kv.test.ts +80 -59
- package/src/__tests__/publish.test.ts +76 -0
- package/src/__tests__/version.test.ts +35 -0
- package/src/api/dev.ts +43 -9
- package/src/bundle.ts +30 -4
- package/src/config/config.ts +7 -0
- package/src/config/validation.ts +9 -1
- package/src/create-worker-preview.ts +3 -1
- package/src/dev/dev.tsx +28 -3
- package/src/dev/local.tsx +28 -10
- package/src/dev/remote.tsx +0 -4
- package/src/dev.tsx +82 -28
- package/src/index.tsx +40 -3
- package/src/miniflare-cli/assets.ts +543 -0
- package/src/miniflare-cli/index.ts +36 -4
- package/src/pages/dev.tsx +79 -638
- package/src/publish.ts +13 -0
- package/src/user/choose-account.tsx +20 -11
- package/templates/pages-shim.ts +9 -0
- package/wrangler-dist/cli.d.ts +32 -3
- package/wrangler-dist/cli.js +578 -5756
package/src/config/validation.ts
CHANGED
|
@@ -359,6 +359,7 @@ function normalizeAndValidateDev(
|
|
|
359
359
|
const {
|
|
360
360
|
ip = "localhost",
|
|
361
361
|
port,
|
|
362
|
+
inspector_port,
|
|
362
363
|
local_protocol = "http",
|
|
363
364
|
upstream_protocol = "https",
|
|
364
365
|
host,
|
|
@@ -368,6 +369,13 @@ function normalizeAndValidateDev(
|
|
|
368
369
|
|
|
369
370
|
validateOptionalProperty(diagnostics, "dev", "ip", ip, "string");
|
|
370
371
|
validateOptionalProperty(diagnostics, "dev", "port", port, "number");
|
|
372
|
+
validateOptionalProperty(
|
|
373
|
+
diagnostics,
|
|
374
|
+
"dev",
|
|
375
|
+
"inspector_port",
|
|
376
|
+
inspector_port,
|
|
377
|
+
"number"
|
|
378
|
+
);
|
|
371
379
|
validateOptionalProperty(
|
|
372
380
|
diagnostics,
|
|
373
381
|
"dev",
|
|
@@ -385,7 +393,7 @@ function normalizeAndValidateDev(
|
|
|
385
393
|
["http", "https"]
|
|
386
394
|
);
|
|
387
395
|
validateOptionalProperty(diagnostics, "dev", "host", host, "string");
|
|
388
|
-
return { ip, port, local_protocol, upstream_protocol, host };
|
|
396
|
+
return { ip, port, inspector_port, local_protocol, upstream_protocol, host };
|
|
389
397
|
}
|
|
390
398
|
|
|
391
399
|
/**
|
|
@@ -247,7 +247,9 @@ export async function createWorkerPreview(
|
|
|
247
247
|
}
|
|
248
248
|
},
|
|
249
249
|
(err) => {
|
|
250
|
-
|
|
250
|
+
if ((err as { code: string }).code !== "ABORT_ERR") {
|
|
251
|
+
logger.warn("worker failed to prewarm: ", err);
|
|
252
|
+
}
|
|
251
253
|
}
|
|
252
254
|
);
|
|
253
255
|
|
package/src/dev/dev.tsx
CHANGED
|
@@ -19,6 +19,7 @@ import { useEsbuild } from "./use-esbuild";
|
|
|
19
19
|
import type { Config } from "../config";
|
|
20
20
|
import type { Route } from "../config/environment";
|
|
21
21
|
import type { Entry } from "../entry";
|
|
22
|
+
import type { EnablePagesAssetsServiceBindingOptions } from "../miniflare-cli";
|
|
22
23
|
import type { AssetPaths } from "../sites";
|
|
23
24
|
import type { CfWorkerInit } from "../worker";
|
|
24
25
|
|
|
@@ -39,6 +40,7 @@ export type DevProps = {
|
|
|
39
40
|
localProtocol: "https" | "http";
|
|
40
41
|
localUpstream: string | undefined;
|
|
41
42
|
enableLocalPersistence: boolean;
|
|
43
|
+
liveReload: boolean;
|
|
42
44
|
bindings: CfWorkerInit["bindings"];
|
|
43
45
|
define: Config["define"];
|
|
44
46
|
crons: Config["triggers"]["crons"];
|
|
@@ -57,8 +59,11 @@ export type DevProps = {
|
|
|
57
59
|
routes: Route[] | undefined;
|
|
58
60
|
inspect: boolean;
|
|
59
61
|
logLevel: "none" | "error" | "log" | "warn" | "debug" | undefined;
|
|
62
|
+
logPrefix?: string;
|
|
60
63
|
onReady: (() => void) | undefined;
|
|
61
64
|
showInteractiveDevSession: boolean | undefined;
|
|
65
|
+
forceLocal: boolean | undefined;
|
|
66
|
+
enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
|
|
62
67
|
};
|
|
63
68
|
|
|
64
69
|
export function DevImplementation(props: DevProps): JSX.Element {
|
|
@@ -111,6 +116,7 @@ function InteractiveDevSession(props: DevProps) {
|
|
|
111
116
|
inspectorPort: props.inspectorPort,
|
|
112
117
|
inspect: props.inspect,
|
|
113
118
|
localProtocol: props.localProtocol,
|
|
119
|
+
forceLocal: props.forceLocal,
|
|
114
120
|
});
|
|
115
121
|
|
|
116
122
|
useTunnel(toggles.tunnel);
|
|
@@ -127,8 +133,12 @@ function InteractiveDevSession(props: DevProps) {
|
|
|
127
133
|
<Text> open Devtools, </Text>
|
|
128
134
|
</>
|
|
129
135
|
) : null}
|
|
130
|
-
|
|
131
|
-
|
|
136
|
+
{!props.forceLocal ? (
|
|
137
|
+
<>
|
|
138
|
+
<Text bold={true}>[l]</Text>
|
|
139
|
+
<Text> {toggles.local ? "turn off" : "turn on"} local mode, </Text>
|
|
140
|
+
</>
|
|
141
|
+
) : null}
|
|
132
142
|
<Text bold={true}>[c]</Text>
|
|
133
143
|
<Text> clear console, </Text>
|
|
134
144
|
<Text bold={true}>[x]</Text>
|
|
@@ -178,12 +188,15 @@ function DevSession(props: DevSessionProps) {
|
|
|
178
188
|
rules={props.rules}
|
|
179
189
|
inspectorPort={props.inspectorPort}
|
|
180
190
|
enableLocalPersistence={props.enableLocalPersistence}
|
|
191
|
+
liveReload={props.liveReload}
|
|
181
192
|
crons={props.crons}
|
|
182
193
|
localProtocol={props.localProtocol}
|
|
183
194
|
localUpstream={props.localUpstream}
|
|
184
195
|
logLevel={props.logLevel}
|
|
196
|
+
logPrefix={props.logPrefix}
|
|
185
197
|
inspect={props.inspect}
|
|
186
198
|
onReady={props.onReady}
|
|
199
|
+
enablePagesAssetsServiceBinding={props.enablePagesAssetsServiceBinding}
|
|
187
200
|
/>
|
|
188
201
|
) : (
|
|
189
202
|
<Remote
|
|
@@ -198,6 +211,8 @@ function DevSession(props: DevSessionProps) {
|
|
|
198
211
|
ip={props.ip}
|
|
199
212
|
localProtocol={props.localProtocol}
|
|
200
213
|
inspectorPort={props.inspectorPort}
|
|
214
|
+
// TODO: @threepointone #1167
|
|
215
|
+
// liveReload={props.liveReload}
|
|
201
216
|
inspect={props.inspect}
|
|
202
217
|
compatibilityDate={props.compatibilityDate}
|
|
203
218
|
compatibilityFlags={props.compatibilityFlags}
|
|
@@ -359,8 +374,17 @@ function useHotkeys(props: {
|
|
|
359
374
|
inspectorPort: number;
|
|
360
375
|
inspect: boolean;
|
|
361
376
|
localProtocol: "http" | "https";
|
|
377
|
+
forceLocal: boolean | undefined;
|
|
362
378
|
}) {
|
|
363
|
-
const {
|
|
379
|
+
const {
|
|
380
|
+
initial,
|
|
381
|
+
port,
|
|
382
|
+
ip,
|
|
383
|
+
inspectorPort,
|
|
384
|
+
inspect,
|
|
385
|
+
localProtocol,
|
|
386
|
+
forceLocal,
|
|
387
|
+
} = props;
|
|
364
388
|
// UGH, we should put port in context instead
|
|
365
389
|
const [toggles, setToggles] = useState(initial);
|
|
366
390
|
const { exit } = useApp();
|
|
@@ -392,6 +416,7 @@ function useHotkeys(props: {
|
|
|
392
416
|
}
|
|
393
417
|
// toggle local
|
|
394
418
|
case "l":
|
|
419
|
+
if (forceLocal) return;
|
|
395
420
|
setToggles((previousToggles) => ({
|
|
396
421
|
...previousToggles,
|
|
397
422
|
local: !previousToggles.local,
|
package/src/dev/local.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import { logger } from "../logger";
|
|
|
9
9
|
import { DEFAULT_MODULE_RULES } from "../module-collection";
|
|
10
10
|
import { waitForPortToBeAvailable } from "../proxy";
|
|
11
11
|
import type { Config } from "../config";
|
|
12
|
+
import type { EnablePagesAssetsServiceBindingOptions } from "../miniflare-cli";
|
|
12
13
|
import type { AssetPaths } from "../sites";
|
|
13
14
|
import type { CfWorkerInit, CfScriptFormat } from "../worker";
|
|
14
15
|
import type { EsbuildBundle } from "./use-esbuild";
|
|
@@ -28,12 +29,15 @@ interface LocalProps {
|
|
|
28
29
|
rules: Config["rules"];
|
|
29
30
|
inspectorPort: number;
|
|
30
31
|
enableLocalPersistence: boolean;
|
|
32
|
+
liveReload: boolean;
|
|
31
33
|
crons: Config["triggers"]["crons"];
|
|
32
34
|
localProtocol: "http" | "https";
|
|
33
35
|
localUpstream: string | undefined;
|
|
34
36
|
inspect: boolean;
|
|
35
37
|
onReady: (() => void) | undefined;
|
|
36
38
|
logLevel: "none" | "error" | "log" | "warn" | "debug" | undefined;
|
|
39
|
+
logPrefix?: string;
|
|
40
|
+
enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
export function Local(props: LocalProps) {
|
|
@@ -56,8 +60,10 @@ function useLocalWorker({
|
|
|
56
60
|
assetPaths,
|
|
57
61
|
isWorkersSite,
|
|
58
62
|
port,
|
|
63
|
+
inspectorPort,
|
|
59
64
|
rules,
|
|
60
65
|
enableLocalPersistence,
|
|
66
|
+
liveReload,
|
|
61
67
|
ip,
|
|
62
68
|
crons,
|
|
63
69
|
localProtocol,
|
|
@@ -65,6 +71,8 @@ function useLocalWorker({
|
|
|
65
71
|
inspect,
|
|
66
72
|
onReady,
|
|
67
73
|
logLevel,
|
|
74
|
+
logPrefix,
|
|
75
|
+
enablePagesAssetsServiceBinding,
|
|
68
76
|
}: LocalProps) {
|
|
69
77
|
// TODO: pass vars via command line
|
|
70
78
|
const local = useRef<ChildProcess>();
|
|
@@ -212,6 +220,7 @@ function useLocalWorker({
|
|
|
212
220
|
r2Persist: true,
|
|
213
221
|
}),
|
|
214
222
|
|
|
223
|
+
liveReload,
|
|
215
224
|
sitePath: assetPaths?.assetDirectory
|
|
216
225
|
? path.join(assetPaths.baseDirectory, assetPaths.assetDirectory)
|
|
217
226
|
: undefined,
|
|
@@ -230,6 +239,7 @@ function useLocalWorker({
|
|
|
230
239
|
crons,
|
|
231
240
|
upstream,
|
|
232
241
|
disableLogs: logLevel === "none",
|
|
242
|
+
logOptions: logPrefix ? { prefix: logPrefix } : undefined,
|
|
233
243
|
};
|
|
234
244
|
|
|
235
245
|
// The path to the Miniflare CLI assumes that this file is being run from
|
|
@@ -248,17 +258,21 @@ function useLocalWorker({
|
|
|
248
258
|
// "--log=VERBOSE", // uncomment this to Miniflare to log "everything"!
|
|
249
259
|
];
|
|
250
260
|
if (inspect) {
|
|
251
|
-
nodeOptions.push("--inspect"); // start Miniflare listening for a debugger to attach
|
|
261
|
+
nodeOptions.push("--inspect=" + `${ip}:${inspectorPort}`); // start Miniflare listening for a debugger to attach
|
|
252
262
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
|
|
264
|
+
const forkOptions = [miniflareOptions];
|
|
265
|
+
|
|
266
|
+
if (enablePagesAssetsServiceBinding) {
|
|
267
|
+
forkOptions.push(JSON.stringify(enablePagesAssetsServiceBinding));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const child = (local.current = fork(miniflareCLIPath, forkOptions, {
|
|
271
|
+
cwd: path.dirname(scriptPath),
|
|
272
|
+
execArgv: nodeOptions,
|
|
273
|
+
stdio: "pipe",
|
|
274
|
+
}));
|
|
275
|
+
|
|
262
276
|
child.on("message", (message) => {
|
|
263
277
|
if (message === "ready") {
|
|
264
278
|
onReady?.();
|
|
@@ -331,6 +345,7 @@ function useLocalWorker({
|
|
|
331
345
|
workerName,
|
|
332
346
|
format,
|
|
333
347
|
port,
|
|
348
|
+
inspectorPort,
|
|
334
349
|
ip,
|
|
335
350
|
bindings.durable_objects?.bindings,
|
|
336
351
|
bindings.kv_namespaces,
|
|
@@ -340,6 +355,7 @@ function useLocalWorker({
|
|
|
340
355
|
compatibilityDate,
|
|
341
356
|
compatibilityFlags,
|
|
342
357
|
localPersistencePath,
|
|
358
|
+
liveReload,
|
|
343
359
|
assetPaths,
|
|
344
360
|
isWorkersSite,
|
|
345
361
|
rules,
|
|
@@ -351,7 +367,9 @@ function useLocalWorker({
|
|
|
351
367
|
localUpstream,
|
|
352
368
|
inspect,
|
|
353
369
|
logLevel,
|
|
370
|
+
logPrefix,
|
|
354
371
|
onReady,
|
|
372
|
+
enablePagesAssetsServiceBinding,
|
|
355
373
|
]);
|
|
356
374
|
return { inspectorUrl };
|
|
357
375
|
}
|
package/src/dev/remote.tsx
CHANGED
|
@@ -69,7 +69,6 @@ export function Remote(props: {
|
|
|
69
69
|
bindings: props.bindings,
|
|
70
70
|
assetPaths: props.assetPaths,
|
|
71
71
|
isWorkersSite: props.isWorkersSite,
|
|
72
|
-
port: props.port,
|
|
73
72
|
compatibilityDate: props.compatibilityDate,
|
|
74
73
|
compatibilityFlags: props.compatibilityFlags,
|
|
75
74
|
usageModel: props.usageModel,
|
|
@@ -153,7 +152,6 @@ export function useWorker(props: {
|
|
|
153
152
|
bindings: CfWorkerInit["bindings"];
|
|
154
153
|
assetPaths: AssetPaths | undefined;
|
|
155
154
|
isWorkersSite: boolean;
|
|
156
|
-
port: number;
|
|
157
155
|
compatibilityDate: string | undefined;
|
|
158
156
|
compatibilityFlags: string[] | undefined;
|
|
159
157
|
usageModel: "bundled" | "unbound" | undefined;
|
|
@@ -175,7 +173,6 @@ export function useWorker(props: {
|
|
|
175
173
|
compatibilityDate,
|
|
176
174
|
compatibilityFlags,
|
|
177
175
|
usageModel,
|
|
178
|
-
port,
|
|
179
176
|
onReady,
|
|
180
177
|
} = props;
|
|
181
178
|
const [session, setSession] = useState<CfPreviewSession | undefined>();
|
|
@@ -366,7 +363,6 @@ export function useWorker(props: {
|
|
|
366
363
|
bundle,
|
|
367
364
|
format,
|
|
368
365
|
accountId,
|
|
369
|
-
port,
|
|
370
366
|
assetPaths,
|
|
371
367
|
props.isWorkersSite,
|
|
372
368
|
compatibilityDate,
|
package/src/dev.tsx
CHANGED
|
@@ -22,10 +22,12 @@ import {
|
|
|
22
22
|
getDevCompatibilityDate,
|
|
23
23
|
getRules,
|
|
24
24
|
isLegacyEnv,
|
|
25
|
+
DEFAULT_INSPECTOR_PORT,
|
|
25
26
|
} from "./index";
|
|
26
27
|
|
|
27
28
|
import type { Config } from "./config";
|
|
28
29
|
import type { Route } from "./config/environment";
|
|
30
|
+
import type { EnablePagesAssetsServiceBindingOptions } from "./miniflare-cli";
|
|
29
31
|
import type { CfWorkerInit } from "./worker";
|
|
30
32
|
import type { RequestInit } from "undici";
|
|
31
33
|
import type { Argv, ArgumentsCamelCase } from "yargs";
|
|
@@ -63,8 +65,10 @@ interface DevArgs {
|
|
|
63
65
|
minify?: boolean;
|
|
64
66
|
"node-compat"?: boolean;
|
|
65
67
|
"experimental-enable-local-persistence"?: boolean;
|
|
68
|
+
"live-reload"?: boolean;
|
|
66
69
|
onReady?: () => void;
|
|
67
70
|
logLevel?: "none" | "error" | "log" | "warn" | "debug";
|
|
71
|
+
logPrefix?: string;
|
|
68
72
|
showInteractiveDevSession?: boolean;
|
|
69
73
|
}
|
|
70
74
|
|
|
@@ -225,6 +229,12 @@ export function devOptions(yargs: Argv): Argv<DevArgs> {
|
|
|
225
229
|
describe: "Enable persistence for this session (only for local mode)",
|
|
226
230
|
type: "boolean",
|
|
227
231
|
})
|
|
232
|
+
.option("live-reload", {
|
|
233
|
+
// TODO: Add back in once we have remote `--live-reload`
|
|
234
|
+
hidden: true,
|
|
235
|
+
// describe: "Auto reload HTML pages when change is detected",
|
|
236
|
+
type: "boolean",
|
|
237
|
+
})
|
|
228
238
|
.option("inspect", {
|
|
229
239
|
describe: "Enable dev tools",
|
|
230
240
|
type: "boolean",
|
|
@@ -250,7 +260,28 @@ export async function devHandler(args: ArgumentsCamelCase<DevArgs>) {
|
|
|
250
260
|
}
|
|
251
261
|
}
|
|
252
262
|
|
|
253
|
-
|
|
263
|
+
type StartDevOptions = ArgumentsCamelCase<DevArgs> & {
|
|
264
|
+
// These options can be passed in directly when called with the `wrangler.dev()` API.
|
|
265
|
+
// They aren't exposed as CLI arguments.
|
|
266
|
+
vars?: {
|
|
267
|
+
[key: string]: unknown;
|
|
268
|
+
};
|
|
269
|
+
kv?: {
|
|
270
|
+
binding: string;
|
|
271
|
+
id: string;
|
|
272
|
+
preview_id?: string;
|
|
273
|
+
}[];
|
|
274
|
+
durableObjects?: {
|
|
275
|
+
name: string;
|
|
276
|
+
class_name: string;
|
|
277
|
+
script_name?: string | undefined;
|
|
278
|
+
environment?: string | undefined;
|
|
279
|
+
}[];
|
|
280
|
+
forceLocal?: boolean;
|
|
281
|
+
enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export async function startDev(args: StartDevOptions) {
|
|
254
285
|
let watcher: ReturnType<typeof watch> | undefined;
|
|
255
286
|
let rerender: (node: React.ReactNode) => void | undefined;
|
|
256
287
|
try {
|
|
@@ -351,6 +382,10 @@ export async function startDev(args: ArgumentsCamelCase<DevArgs>) {
|
|
|
351
382
|
const routes: Route[] | undefined =
|
|
352
383
|
args.routes || (config.route && [config.route]) || config.routes;
|
|
353
384
|
|
|
385
|
+
if (args.forceLocal) {
|
|
386
|
+
args.local = true;
|
|
387
|
+
}
|
|
388
|
+
|
|
354
389
|
if (!args.local) {
|
|
355
390
|
if (host) {
|
|
356
391
|
zoneId = await getZoneIdFromHost(host);
|
|
@@ -370,7 +405,7 @@ export async function startDev(args: ArgumentsCamelCase<DevArgs>) {
|
|
|
370
405
|
}
|
|
371
406
|
}
|
|
372
407
|
|
|
373
|
-
const nodeCompat = args
|
|
408
|
+
const nodeCompat = args.nodeCompat ?? config.node_compat;
|
|
374
409
|
if (nodeCompat) {
|
|
375
410
|
logger.warn(
|
|
376
411
|
"Enabling node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details."
|
|
@@ -382,33 +417,44 @@ export async function startDev(args: ArgumentsCamelCase<DevArgs>) {
|
|
|
382
417
|
configParam: Config
|
|
383
418
|
): Promise<CfWorkerInit["bindings"]> {
|
|
384
419
|
return {
|
|
385
|
-
kv_namespaces:
|
|
386
|
-
(
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
420
|
+
kv_namespaces: [
|
|
421
|
+
...(configParam.kv_namespaces || []).map(
|
|
422
|
+
({ binding, preview_id, id: _id }) => {
|
|
423
|
+
// In `dev`, we make folks use a separate kv namespace called
|
|
424
|
+
// `preview_id` instead of `id` so that they don't
|
|
425
|
+
// break production data. So here we check that a `preview_id`
|
|
426
|
+
// has actually been configured.
|
|
427
|
+
// This whole block of code will be obsoleted in the future
|
|
428
|
+
// when we have copy-on-write for previews on edge workers.
|
|
429
|
+
if (!preview_id) {
|
|
430
|
+
// TODO: This error has to be a _lot_ better, ideally just asking
|
|
431
|
+
// to create a preview namespace for the user automatically
|
|
432
|
+
throw new Error(
|
|
433
|
+
`In development, you should use a separate kv namespace than the one you'd use in production. Please create a new kv namespace with "wrangler kv:namespace create <name> --preview" and add its id as preview_id to the kv_namespace "${binding}" in your wrangler.toml`
|
|
434
|
+
); // Ugh, I really don't like this message very much
|
|
435
|
+
}
|
|
436
|
+
return {
|
|
437
|
+
binding,
|
|
438
|
+
id: preview_id,
|
|
439
|
+
};
|
|
399
440
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
),
|
|
441
|
+
),
|
|
442
|
+
...(args.kv || []),
|
|
443
|
+
],
|
|
406
444
|
// Use a copy of combinedVars since we're modifying it later
|
|
407
|
-
vars:
|
|
445
|
+
vars: {
|
|
446
|
+
...getVarsForDev(configParam),
|
|
447
|
+
...args.vars,
|
|
448
|
+
},
|
|
408
449
|
wasm_modules: configParam.wasm_modules,
|
|
409
450
|
text_blobs: configParam.text_blobs,
|
|
410
451
|
data_blobs: configParam.data_blobs,
|
|
411
|
-
durable_objects:
|
|
452
|
+
durable_objects: {
|
|
453
|
+
bindings: [
|
|
454
|
+
...(configParam.durable_objects || { bindings: [] }).bindings,
|
|
455
|
+
...(args.durableObjects || []),
|
|
456
|
+
],
|
|
457
|
+
},
|
|
412
458
|
r2_buckets: configParam.r2_buckets?.map(
|
|
413
459
|
({ binding, preview_bucket_name, bucket_name: _bucket_name }) => {
|
|
414
460
|
// same idea as kv namespace preview id,
|
|
@@ -431,7 +477,7 @@ export async function startDev(args: ArgumentsCamelCase<DevArgs>) {
|
|
|
431
477
|
}
|
|
432
478
|
|
|
433
479
|
const getLocalPort = memoizeGetPort(DEFAULT_LOCAL_PORT);
|
|
434
|
-
const getInspectorPort = memoizeGetPort(
|
|
480
|
+
const getInspectorPort = memoizeGetPort(DEFAULT_INSPECTOR_PORT);
|
|
435
481
|
|
|
436
482
|
// eslint-disable-next-line no-inner-declarations
|
|
437
483
|
async function getDevReactElement(configParam: Config) {
|
|
@@ -483,16 +529,21 @@ export async function startDev(args: ArgumentsCamelCase<DevArgs>) {
|
|
|
483
529
|
jsxFragment={args["jsx-fragment"] || config.jsx_fragment}
|
|
484
530
|
tsconfig={args.tsconfig ?? config.tsconfig}
|
|
485
531
|
upstreamProtocol={upstreamProtocol}
|
|
486
|
-
localProtocol={args
|
|
532
|
+
localProtocol={args.localProtocol || config.dev.local_protocol}
|
|
487
533
|
localUpstream={args["local-upstream"] || host}
|
|
488
534
|
enableLocalPersistence={
|
|
489
|
-
args
|
|
535
|
+
args.experimentalEnableLocalPersistence || false
|
|
490
536
|
}
|
|
537
|
+
liveReload={args.liveReload || false}
|
|
491
538
|
accountId={config.account_id || getAccountFromCache()?.id}
|
|
492
539
|
assetPaths={assetPaths}
|
|
493
540
|
port={args.port || config.dev.port || (await getLocalPort())}
|
|
494
541
|
ip={args.ip || config.dev.ip}
|
|
495
|
-
inspectorPort={
|
|
542
|
+
inspectorPort={
|
|
543
|
+
args["inspector-port"] ||
|
|
544
|
+
config.dev.inspector_port ||
|
|
545
|
+
(await getInspectorPort())
|
|
546
|
+
}
|
|
496
547
|
isWorkersSite={Boolean(args.site || config.site)}
|
|
497
548
|
compatibilityDate={getDevCompatibilityDate(
|
|
498
549
|
config,
|
|
@@ -505,9 +556,12 @@ export async function startDev(args: ArgumentsCamelCase<DevArgs>) {
|
|
|
505
556
|
bindings={bindings}
|
|
506
557
|
crons={config.triggers.crons}
|
|
507
558
|
logLevel={args.logLevel}
|
|
559
|
+
logPrefix={args.logPrefix}
|
|
508
560
|
onReady={args.onReady}
|
|
509
561
|
inspect={args.inspect ?? true}
|
|
510
562
|
showInteractiveDevSession={args.showInteractiveDevSession}
|
|
563
|
+
forceLocal={args.forceLocal}
|
|
564
|
+
enablePagesAssetsServiceBinding={args.enablePagesAssetsServiceBinding}
|
|
511
565
|
/>
|
|
512
566
|
);
|
|
513
567
|
}
|
package/src/index.tsx
CHANGED
|
@@ -76,6 +76,7 @@ export type ConfigPath = string | undefined;
|
|
|
76
76
|
const resetColor = "\x1b[0m";
|
|
77
77
|
const fgGreenColor = "\x1b[32m";
|
|
78
78
|
export const DEFAULT_LOCAL_PORT = 8787;
|
|
79
|
+
export const DEFAULT_INSPECTOR_PORT = 9229;
|
|
79
80
|
|
|
80
81
|
const proxy =
|
|
81
82
|
process.env.https_proxy ||
|
|
@@ -258,11 +259,22 @@ function createCLIParser(argv: string[]) {
|
|
|
258
259
|
["*"],
|
|
259
260
|
false,
|
|
260
261
|
() => {},
|
|
261
|
-
(args) => {
|
|
262
|
+
async (args) => {
|
|
262
263
|
if (args._.length > 0) {
|
|
263
264
|
throw new CommandLineArgsError(`Unknown command: ${args._}.`);
|
|
264
265
|
} else {
|
|
265
|
-
|
|
266
|
+
// args.v will exist and be true in the case that no command is called, and the -v
|
|
267
|
+
// option is present. This is to allow for running asynchronous printWranglerBanner
|
|
268
|
+
// in the version command.
|
|
269
|
+
if (args.v) {
|
|
270
|
+
if (process.stdout.isTTY) {
|
|
271
|
+
await printWranglerBanner();
|
|
272
|
+
} else {
|
|
273
|
+
logger.log(wranglerVersion);
|
|
274
|
+
}
|
|
275
|
+
} else {
|
|
276
|
+
wrangler.showHelp("log");
|
|
277
|
+
}
|
|
266
278
|
}
|
|
267
279
|
}
|
|
268
280
|
);
|
|
@@ -1220,7 +1232,9 @@ function createCLIParser(argv: string[]) {
|
|
|
1220
1232
|
|
|
1221
1233
|
const accountId = await requireAuth(config);
|
|
1222
1234
|
|
|
1235
|
+
logger.log(`Deleting KV namespace ${id}.`);
|
|
1223
1236
|
await deleteKVNamespace(accountId, id);
|
|
1237
|
+
logger.log(`Deleted KV namespace ${id}.`);
|
|
1224
1238
|
await metrics.sendMetricsEvent("delete kv namespace", {
|
|
1225
1239
|
sendMetrics: config.send_metrics,
|
|
1226
1240
|
});
|
|
@@ -1903,6 +1917,29 @@ function createCLIParser(argv: string[]) {
|
|
|
1903
1917
|
}
|
|
1904
1918
|
);
|
|
1905
1919
|
|
|
1920
|
+
// This set to false to allow overwrite of default behaviour
|
|
1921
|
+
wrangler.version(false);
|
|
1922
|
+
|
|
1923
|
+
// version
|
|
1924
|
+
wrangler.command(
|
|
1925
|
+
"version",
|
|
1926
|
+
false,
|
|
1927
|
+
() => {},
|
|
1928
|
+
async () => {
|
|
1929
|
+
if (process.stdout.isTTY) {
|
|
1930
|
+
await printWranglerBanner();
|
|
1931
|
+
} else {
|
|
1932
|
+
logger.log(wranglerVersion);
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
);
|
|
1936
|
+
|
|
1937
|
+
wrangler.option("v", {
|
|
1938
|
+
describe: "Show version number",
|
|
1939
|
+
alias: "version",
|
|
1940
|
+
type: "boolean",
|
|
1941
|
+
});
|
|
1942
|
+
|
|
1906
1943
|
wrangler.option("config", {
|
|
1907
1944
|
alias: "c",
|
|
1908
1945
|
describe: "Path to .toml configuration file",
|
|
@@ -1912,7 +1949,7 @@ function createCLIParser(argv: string[]) {
|
|
|
1912
1949
|
|
|
1913
1950
|
wrangler.group(["config", "help", "version"], "Flags:");
|
|
1914
1951
|
wrangler.help().alias("h", "help");
|
|
1915
|
-
|
|
1952
|
+
|
|
1916
1953
|
wrangler.exitProcess(false);
|
|
1917
1954
|
|
|
1918
1955
|
return wrangler;
|