wrangler 2.0.19 → 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.
@@ -44,8 +44,11 @@ export async function ListHandler() {
44
44
  account_id: accountId,
45
45
  });
46
46
 
47
- render(<Table data={data}></Table>, { patchConsole: false });
48
- metrics.sendMetricsEvent("list pages projects");
47
+ const { unmount } = render(<Table data={data}></Table>, {
48
+ patchConsole: false,
49
+ });
50
+ unmount();
51
+ await metrics.sendMetricsEvent("list pages projects");
49
52
  }
50
53
 
51
54
  export const listProjects = async ({
@@ -156,5 +159,5 @@ export async function CreateHandler({
156
159
  logger.log(
157
160
  `To deploy a folder of assets, run 'wrangler pages publish [directory]'.`
158
161
  );
159
- metrics.sendMetricsEvent("create pages project");
162
+ await metrics.sendMetricsEvent("create pages project");
160
163
  }
@@ -194,7 +194,7 @@ export const Handler = async ({
194
194
  });
195
195
 
196
196
  logger.log(`✨ Successfully created the '${projectName}' project.`);
197
- metrics.sendMetricsEvent("create pages project");
197
+ await metrics.sendMetricsEvent("create pages project");
198
198
  break;
199
199
  }
200
200
  }
@@ -334,5 +334,5 @@ export const Handler = async ({
334
334
  logger.log(
335
335
  `✨ Deployment complete! Take a peek over at ${deploymentResponse.url}`
336
336
  );
337
- metrics.sendMetricsEvent("deploy pages project");
337
+ await metrics.sendMetricsEvent("deploy pages project");
338
338
  };
package/src/publish.ts CHANGED
@@ -276,6 +276,19 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
276
276
  );
277
277
  }
278
278
 
279
+ // Warn if user tries minify or node-compat with no-bundle
280
+ if (props.noBundle && minify) {
281
+ logger.warn(
282
+ "`--minify` and `--no-bundle` can't be used together. If you want to minify your Worker and disable Wrangler's bundling, please minify as part of your own bundling process."
283
+ );
284
+ }
285
+
286
+ if (props.noBundle && nodeCompat) {
287
+ logger.warn(
288
+ "`--node-compat` and `--no-bundle` can't be used together. If you want to polyfill Node.js built-ins and disable Wrangler's bundling, please polyfill as part of your own bundling process."
289
+ );
290
+ }
291
+
279
292
  const scriptName = props.name;
280
293
  assert(
281
294
  scriptName,
@@ -51,7 +51,7 @@ export function pubSubCommands(
51
51
  logger.log(`Creating Pub/SubNamespace ${args.name}...`);
52
52
  await pubsub.createPubSubNamespace(accountId, namespace);
53
53
  logger.log(`Success! Created Pub/Sub Namespace ${args.name}`);
54
- metrics.sendMetricsEvent("create pubsub namespace", {
54
+ await metrics.sendMetricsEvent("create pubsub namespace", {
55
55
  sendMetrics: config.send_metrics,
56
56
  });
57
57
  }
@@ -67,7 +67,7 @@ export function pubSubCommands(
67
67
  const accountId = await requireAuth(config);
68
68
 
69
69
  logger.log(await pubsub.listPubSubNamespaces(accountId));
70
- metrics.sendMetricsEvent("list pubsub namespaces", {
70
+ await metrics.sendMetricsEvent("list pubsub namespaces", {
71
71
  sendMetrics: config.send_metrics,
72
72
  });
73
73
  }
@@ -96,7 +96,7 @@ export function pubSubCommands(
96
96
  logger.log(`Deleting namespace ${args.name}...`);
97
97
  await pubsub.deletePubSubNamespace(accountId, args.name);
98
98
  logger.log(`Deleted namespace ${args.name}.`);
99
- metrics.sendMetricsEvent("delete pubsub namespace", {
99
+ await metrics.sendMetricsEvent("delete pubsub namespace", {
100
100
  sendMetrics: config.send_metrics,
101
101
  });
102
102
  }
@@ -121,7 +121,7 @@ export function pubSubCommands(
121
121
  logger.log(
122
122
  await pubsub.describePubSubNamespace(accountId, args.name)
123
123
  );
124
- metrics.sendMetricsEvent("view pubsub namespace", {
124
+ await metrics.sendMetricsEvent("view pubsub namespace", {
125
125
  sendMetrics: config.send_metrics,
126
126
  });
127
127
  }
@@ -191,7 +191,7 @@ export function pubSubCommands(
191
191
  logger.log(
192
192
  await pubsub.createPubSubBroker(accountId, args.namespace, broker)
193
193
  );
194
- metrics.sendMetricsEvent("create pubsub broker", {
194
+ await metrics.sendMetricsEvent("create pubsub broker", {
195
195
  sendMetrics: config.send_metrics,
196
196
  });
197
197
  }
@@ -263,7 +263,7 @@ export function pubSubCommands(
263
263
  )
264
264
  );
265
265
  logger.log(`Successfully updated Pub/Sub Broker ${args.name}`);
266
- metrics.sendMetricsEvent("update pubsub broker", {
266
+ await metrics.sendMetricsEvent("update pubsub broker", {
267
267
  sendMetrics: config.send_metrics,
268
268
  });
269
269
  }
@@ -287,7 +287,7 @@ export function pubSubCommands(
287
287
  const accountId = await requireAuth(config);
288
288
 
289
289
  logger.log(await pubsub.listPubSubBrokers(accountId, args.namespace));
290
- metrics.sendMetricsEvent("list pubsub brokers", {
290
+ await metrics.sendMetricsEvent("list pubsub brokers", {
291
291
  sendMetrics: config.send_metrics,
292
292
  });
293
293
  }
@@ -328,7 +328,7 @@ export function pubSubCommands(
328
328
  args.name
329
329
  );
330
330
  logger.log(`Deleted Pub/Sub Broker ${args.name}.`);
331
- metrics.sendMetricsEvent("delete pubsub broker", {
331
+ await metrics.sendMetricsEvent("delete pubsub broker", {
332
332
  sendMetrics: config.send_metrics,
333
333
  });
334
334
  }
@@ -363,7 +363,7 @@ export function pubSubCommands(
363
363
  args.name
364
364
  )
365
365
  );
366
- metrics.sendMetricsEvent("view pubsub broker", {
366
+ await metrics.sendMetricsEvent("view pubsub broker", {
367
367
  sendMetrics: config.send_metrics,
368
368
  });
369
369
  }
@@ -441,7 +441,7 @@ export function pubSubCommands(
441
441
  parsedExpiration
442
442
  )
443
443
  );
444
- metrics.sendMetricsEvent("issue pubsub broker credentials", {
444
+ await metrics.sendMetricsEvent("issue pubsub broker credentials", {
445
445
  sendMetrics: config.send_metrics,
446
446
  });
447
447
  }
@@ -489,7 +489,7 @@ export function pubSubCommands(
489
489
  );
490
490
 
491
491
  logger.log(`Revoked ${args.jti.length} credential(s).`);
492
- metrics.sendMetricsEvent("revoke pubsub broker credentials", {
492
+ await metrics.sendMetricsEvent("revoke pubsub broker credentials", {
493
493
  sendMetrics: config.send_metrics,
494
494
  });
495
495
  }
@@ -536,7 +536,7 @@ export function pubSubCommands(
536
536
  );
537
537
 
538
538
  logger.log(`Unrevoked ${numTokens} credential(s)`);
539
- metrics.sendMetricsEvent("unrevoke pubsub broker credentials", {
539
+ await metrics.sendMetricsEvent("unrevoke pubsub broker credentials", {
540
540
  sendMetrics: config.send_metrics,
541
541
  });
542
542
  }
@@ -572,9 +572,12 @@ export function pubSubCommands(
572
572
  args.name
573
573
  )
574
574
  );
575
- metrics.sendMetricsEvent("list pubsub broker revoked credentials", {
576
- sendMetrics: config.send_metrics,
577
- });
575
+ await metrics.sendMetricsEvent(
576
+ "list pubsub broker revoked credentials",
577
+ {
578
+ sendMetrics: config.send_metrics,
579
+ }
580
+ );
578
581
  }
579
582
  );
580
583
 
@@ -607,7 +610,7 @@ export function pubSubCommands(
607
610
  args.name
608
611
  )
609
612
  );
610
- metrics.sendMetricsEvent("list pubsub broker public-keys", {
613
+ await metrics.sendMetricsEvent("list pubsub broker public-keys", {
611
614
  sendMetrics: config.send_metrics,
612
615
  });
613
616
  }
@@ -44,17 +44,26 @@ export async function getAccountChoices(): Promise<ChooseAccountItem[]> {
44
44
  if (accountIdFromEnv) {
45
45
  return [{ id: accountIdFromEnv, name: "" }];
46
46
  } else {
47
- const response = await fetchListResult<{
48
- account: ChooseAccountItem;
49
- }>(`/memberships`);
50
- const accounts = response.map((r) => r.account);
51
- if (accounts.length === 0) {
52
- throw new Error(
53
- "Failed to automatically retrieve account IDs for the logged in user.\n" +
54
- "In a non-interactive environment, it is mandatory to specify an account ID, either by assigning its value to CLOUDFLARE_ACCOUNT_ID, or as `account_id` in your `wrangler.toml` file."
55
- );
56
- } else {
57
- return accounts;
47
+ try {
48
+ const response = await fetchListResult<{
49
+ account: ChooseAccountItem;
50
+ }>(`/memberships`);
51
+ const accounts = response.map((r) => r.account);
52
+ if (accounts.length === 0) {
53
+ throw new Error(
54
+ "Failed to automatically retrieve account IDs for the logged in user.\n" +
55
+ "In a non-interactive environment, it is mandatory to specify an account ID, either by assigning its value to CLOUDFLARE_ACCOUNT_ID, or as `account_id` in your `wrangler.toml` file."
56
+ );
57
+ } else {
58
+ return accounts;
59
+ }
60
+ } catch (err) {
61
+ if ((err as { code: number }).code === 9109) {
62
+ throw new Error(
63
+ `Failed to automatically retrieve account IDs for the logged in user.
64
+ You may have incorrect permissions on your API token. You can skip this account check by adding an \`account_id\` in your \`wrangler.toml\`, or by setting the value of CLOUDFLARE_ACCOUNT_ID"`
65
+ );
66
+ } else throw err;
58
67
  }
59
68
  }
60
69
  }
package/src/user/user.tsx CHANGED
@@ -1058,7 +1058,8 @@ export function listScopes(message = "💁 Available scopes:"): void {
1058
1058
  Scope: scope,
1059
1059
  Description: Scopes[scope],
1060
1060
  }));
1061
- render(<Table data={data} />);
1061
+ const { unmount } = render(<Table data={data} />);
1062
+ unmount();
1062
1063
  // TODO: maybe a good idea to show usage here
1063
1064
  }
1064
1065
 
package/src/whoami.tsx CHANGED
@@ -8,7 +8,8 @@ import { getAPIToken, getAuthFromEnv } from "./user";
8
8
  export async function whoami() {
9
9
  logger.log("Getting User settings...");
10
10
  const user = await getUserInfo();
11
- render(<WhoAmI user={user}></WhoAmI>);
11
+ const { unmount } = render(<WhoAmI user={user}></WhoAmI>);
12
+ unmount();
12
13
  }
13
14
 
14
15
  export function WhoAmI({ user }: { user: UserInfo | undefined }) {
@@ -114,7 +114,7 @@ export function workerNamespaceCommands(
114
114
  const config = readConfig(args.config as ConfigPath, args);
115
115
  const accountId = await requireAuth(config);
116
116
  await listWorkerNamespaces(accountId);
117
- metrics.sendMetricsEvent("list worker namespaces", {
117
+ await metrics.sendMetricsEvent("list worker namespaces", {
118
118
  sendMetrics: config.send_metrics,
119
119
  });
120
120
  })
@@ -132,7 +132,7 @@ export function workerNamespaceCommands(
132
132
  const config = readConfig(args.config as ConfigPath, args);
133
133
  const accountId = await requireAuth(config);
134
134
  await getWorkerNamespaceInfo(accountId, args.name);
135
- metrics.sendMetricsEvent("view worker namespace", {
135
+ await metrics.sendMetricsEvent("view worker namespace", {
136
136
  sendMetrics: config.send_metrics,
137
137
  });
138
138
  }
@@ -152,7 +152,7 @@ export function workerNamespaceCommands(
152
152
  const config = readConfig(args.config as ConfigPath, args);
153
153
  const accountId = await requireAuth(config);
154
154
  await createWorkerNamespace(accountId, args.name);
155
- metrics.sendMetricsEvent("create worker namespace", {
155
+ await metrics.sendMetricsEvent("create worker namespace", {
156
156
  sendMetrics: config.send_metrics,
157
157
  });
158
158
  }
@@ -172,7 +172,7 @@ export function workerNamespaceCommands(
172
172
  const config = readConfig(args.config as ConfigPath, args);
173
173
  const accountId = await requireAuth(config);
174
174
  await deleteWorkerNamespace(accountId, args.name);
175
- metrics.sendMetricsEvent("delete worker namespace", {
175
+ await metrics.sendMetricsEvent("delete worker namespace", {
176
176
  sendMetrics: config.send_metrics,
177
177
  });
178
178
  }
@@ -198,7 +198,7 @@ export function workerNamespaceCommands(
198
198
  const config = readConfig(args.config as ConfigPath, args);
199
199
  const accountId = await requireAuth(config);
200
200
  await renameWorkerNamespace(accountId, args.oldName, args.newName);
201
- metrics.sendMetricsEvent("rename worker namespace", {
201
+ await metrics.sendMetricsEvent("rename worker namespace", {
202
202
  sendMetrics: config.send_metrics,
203
203
  });
204
204
  }
@@ -0,0 +1,9 @@
1
+ // This Worker is used as a default when no Pages Functions are present.
2
+ // It proxies the request directly on to the asset server binding.
3
+
4
+ export default {
5
+ async fetch(request, env, context) {
6
+ const response = await env.ASSETS.fetch(request.url, request);
7
+ return new Response(response.body, response);
8
+ },
9
+ };
@@ -39,9 +39,37 @@ declare interface DevOptions {
39
39
  siteInclude?: string[];
40
40
  siteExclude?: string[];
41
41
  nodeCompat?: boolean;
42
+ compatibilityDate?: string;
42
43
  experimentalEnableLocalPersistence?: boolean;
43
- _: (string | number)[];
44
- $0: string;
44
+ liveReload?: boolean;
45
+ watch?: boolean;
46
+ vars: {
47
+ [key: string]: unknown;
48
+ };
49
+ kv?: {
50
+ binding: string;
51
+ id: string;
52
+ preview_id?: string;
53
+ }[];
54
+ durableObjects?: {
55
+ name: string;
56
+ class_name: string;
57
+ script_name?: string | undefined;
58
+ environment?: string | undefined;
59
+ }[];
60
+ showInteractiveDevSession?: boolean;
61
+ logLevel?: "none" | "error" | "log" | "warn" | "debug";
62
+ logPrefix?: string;
63
+ inspect?: boolean;
64
+ forceLocal?: boolean;
65
+ enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
66
+ _?: (string | number)[];
67
+ $0?: string;
68
+ }
69
+
70
+ declare interface EnablePagesAssetsServiceBindingOptions {
71
+ proxyPort?: number;
72
+ directory?: string;
45
73
  }
46
74
 
47
75
  declare class File extends Blob_2 {
@@ -290,9 +318,10 @@ declare interface SpecIterator<T, TReturn = any, TNext = undefined> {
290
318
  * @param {string} script
291
319
  * @param {DevOptions} options
292
320
  */
293
- export declare function unstable_dev(script: string, options: DevOptions): Promise<{
321
+ export declare function unstable_dev(script: string, options: DevOptions, disableExperimentalWarning?: boolean): Promise<{
294
322
  stop: () => void;
295
323
  fetch: (init?: RequestInit | undefined) => Promise<Response | undefined>;
324
+ waitUntilExit: () => Promise<void>;
296
325
  }>;
297
326
 
298
327
  export { }