wrangler 2.3.2 → 2.4.1

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/src/dev.tsx CHANGED
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+ import chalk from "chalk";
2
3
  import { watch } from "chokidar";
3
4
  import getPort from "get-port";
4
5
  import { render } from "ink";
@@ -65,6 +66,7 @@ interface DevArgs {
65
66
  tsconfig?: string;
66
67
  local?: boolean;
67
68
  "experimental-local"?: boolean;
69
+ "experimental-local-remote-kv"?: boolean;
68
70
  minify?: boolean;
69
71
  var?: string[];
70
72
  define?: string[];
@@ -237,11 +239,25 @@ export function devOptions(yargs: Argv<CommonYargsOptions>): Argv<DevArgs> {
237
239
  type: "boolean",
238
240
  default: false,
239
241
  })
242
+ .option("experimental-local-remote-kv", {
243
+ describe:
244
+ "Read/write KV data from/to real namespaces on the Cloudflare network",
245
+ type: "boolean",
246
+ default: false,
247
+ })
240
248
  .check((argv) => {
241
249
  if (argv.local && argv["experimental-local"]) {
242
250
  throw new Error(
243
251
  "--local and --experimental-local are mutually exclusive. " +
244
- "Please select one or the other."
252
+ "Please enable one or the other."
253
+ );
254
+ }
255
+ if (
256
+ argv["experimental-local-remote-kv"] &&
257
+ !argv["experimental-local"]
258
+ ) {
259
+ throw new Error(
260
+ "--experimental-local-remote-kv requires --experimental-local to be enabled."
245
261
  );
246
262
  }
247
263
  return true;
@@ -273,11 +289,20 @@ export function devOptions(yargs: Argv<CommonYargsOptions>): Argv<DevArgs> {
273
289
  requiresArg: true,
274
290
  })
275
291
  .option("live-reload", {
276
- // TODO: Add back in once we have remote `--live-reload`
277
- hidden: true,
278
- // describe: "Auto reload HTML pages when change is detected",
292
+ describe:
293
+ "Auto reload HTML pages when change is detected in local mode",
279
294
  type: "boolean",
280
295
  })
296
+ .check((argv) => {
297
+ const local = argv["local"] || argv["experimental-local"];
298
+ if (argv["live-reload"] && !local) {
299
+ throw new Error(
300
+ "--live-reload is only supported in local mode. " +
301
+ "Please enable either --local or --experimental-local."
302
+ );
303
+ }
304
+ return true;
305
+ })
281
306
  .option("inspect", {
282
307
  describe: "Enable dev tools",
283
308
  type: "boolean",
@@ -354,6 +379,16 @@ export async function startDev(args: StartDevOptions) {
354
379
  }
355
380
  await printWranglerBanner();
356
381
 
382
+ if (args.local && process.platform !== "win32") {
383
+ logger.info(
384
+ chalk.magenta(
385
+ `Want to try out the next version of local mode using the open-source Workers runtime?\nSwitch out --local for ${chalk.bold(
386
+ "--experimental-local"
387
+ )} and let us know what you think at https://discord.gg/cloudflaredev !`
388
+ )
389
+ );
390
+ }
391
+
357
392
  const configPath =
358
393
  (args.config as ConfigPath) ||
359
394
  ((args.script &&
@@ -461,6 +496,7 @@ export async function startDev(args: StartDevOptions) {
461
496
  sendMetrics={configParam.send_metrics}
462
497
  testScheduled={args["test-scheduled"]}
463
498
  experimentalLocal={args.experimentalLocal}
499
+ experimentalLocalRemoteKv={args.experimentalLocalRemoteKv}
464
500
  />
465
501
  );
466
502
  }
@@ -582,6 +618,7 @@ export async function startApiDev(args: StartDevOptions) {
582
618
  sendMetrics: configParam.send_metrics,
583
619
  testScheduled: args.testScheduled,
584
620
  experimentalLocal: args.experimentalLocal,
621
+ experimentalLocalRemoteKv: args.experimentalLocalRemoteKv,
585
622
  });
586
623
  }
587
624
 
package/src/dialogs.tsx CHANGED
@@ -153,8 +153,7 @@ export async function fromDashMessagePrompt(
153
153
  ): Promise<boolean | void> {
154
154
  if (deploySource === "dash") {
155
155
  logger.warn(
156
- `You are about to publish a Workers Service that was last published via the Cloudflare Dashboard.
157
- Edits that have been made via the dashboard will be overridden by your local code and config.`
156
+ `You are about to publish a Workers Service that was last published via the Cloudflare Dashboard.\nEdits that have been made via the dashboard will be overridden by your local code and config.`
158
157
  );
159
158
 
160
159
  if (!isInteractive() || CI.isCI()) return true;
package/src/index.tsx CHANGED
@@ -554,8 +554,7 @@ export function createCLIParser(argv: string[]) {
554
554
  "🚧`wrangler deployments` is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose";
555
555
  wrangler.command(
556
556
  "deployments",
557
- false,
558
- // "🚢 Logs the 10 most recent deployments with 'Version ID', 'Version number','Author email', 'Created on' and 'Latest deploy'",
557
+ "🚢 Displays the 10 most recent deployments for a worker",
559
558
  (yargs) => {
560
559
  yargs
561
560
  .option("name", {
@@ -1,11 +1,11 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { readFileSync, mkdirSync, writeFileSync } from "node:fs";
3
- import os from "node:os";
4
3
  import path from "node:path";
5
4
  import { fetchResult } from "../cfetch";
6
5
  import { getConfigCache, saveToConfigCache } from "../config-cache";
7
6
  import { confirm } from "../dialogs";
8
7
  import { getEnvironmentVariableFactory } from "../environment-variables";
8
+ import { getGlobalWranglerConfigPath } from "../global-wrangler-config-path";
9
9
  import { CI } from "../is-ci";
10
10
  import isInteractive from "../is-interactive";
11
11
  import { logger } from "../logger";
@@ -167,7 +167,7 @@ export function readMetricsConfig(): MetricsConfigFile {
167
167
  * Get the path to the metrics config file.
168
168
  */
169
169
  function getMetricsConfigPath(): string {
170
- return path.resolve(os.homedir(), ".wrangler/config/metrics.json");
170
+ return path.resolve(getGlobalWranglerConfigPath(), "metrics.json");
171
171
  }
172
172
 
173
173
  /**
@@ -275,11 +275,20 @@ export const Handler = async ({
275
275
  ? join(tmpdir(), `_routes-${Math.random()}.json`)
276
276
  : undefined;
277
277
 
278
+ // Routing configuration displayed in the Functions tab of a deployment in Dash
279
+ let filepathRoutingConfig: string | undefined;
280
+
278
281
  if (!_workerJS && existsSync(functionsDirectory)) {
279
282
  const outfile = join(tmpdir(), `./functionsWorker-${Math.random()}.js`);
283
+ const outputConfigPath = join(
284
+ tmpdir(),
285
+ `functions-filepath-routing-config-${Math.random()}.json`
286
+ );
287
+
280
288
  try {
281
289
  await buildFunctions({
282
290
  outfile,
291
+ outputConfigPath,
283
292
  functionsDirectory,
284
293
  onEnd: () => {},
285
294
  buildOutputDirectory: dirname(outfile),
@@ -292,6 +301,7 @@ export const Handler = async ({
292
301
  });
293
302
 
294
303
  builtFunctions = readFileSync(outfile, "utf-8");
304
+ filepathRoutingConfig = readFileSync(outputConfigPath, "utf-8");
295
305
  } catch (e) {
296
306
  if (e instanceof FunctionsNoRoutesError) {
297
307
  logger.warn(
@@ -335,6 +345,16 @@ export const Handler = async ({
335
345
  logger.log(`✨ Uploading _redirects`);
336
346
  }
337
347
 
348
+ if (filepathRoutingConfig) {
349
+ formData.append(
350
+ "functions-filepath-routing-config.json",
351
+ new File(
352
+ [filepathRoutingConfig],
353
+ "functions-filepath-routing-config.json"
354
+ )
355
+ );
356
+ }
357
+
338
358
  /**
339
359
  * Advanced Mode
340
360
  * https://developers.cloudflare.com/pages/platform/functions/#advanced-mode
@@ -487,7 +487,6 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
487
487
  // This could potentially cause issues as we no longer have identical behaviour between dev and publish?
488
488
  targetConsumer: "publish",
489
489
  local: false,
490
- experimentalLocalStubCache: false,
491
490
  }
492
491
  );
493
492
 
@@ -129,6 +129,8 @@ declare interface DevOptions {
129
129
  $0?: string;
130
130
  testScheduled?: boolean;
131
131
  experimentalLocal?: boolean;
132
+ accountId?: string;
133
+ experimentalLocalRemoteKv?: boolean;
132
134
  }
133
135
 
134
136
  declare interface EnablePagesAssetsServiceBindingOptions {