wrangler 3.34.2 → 3.35.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "3.34.2",
3
+ "version": "3.35.0",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -96,7 +96,7 @@
96
96
  "source-map": "0.6.1",
97
97
  "xxhash-wasm": "^1.0.1",
98
98
  "@cloudflare/kv-asset-handler": "0.3.1",
99
- "miniflare": "3.20240304.2"
99
+ "miniflare": "3.20240314.0"
100
100
  },
101
101
  "devDependencies": {
102
102
  "@cloudflare/ai": "^1.0.35",
@@ -187,7 +187,7 @@
187
187
  "yargs": "^17.7.2",
188
188
  "yoga-layout": "file:../../vendor/yoga-layout-2.0.0-beta.1.tgz",
189
189
  "@cloudflare/cli": "1.1.1",
190
- "@cloudflare/pages-shared": "^0.11.19",
190
+ "@cloudflare/pages-shared": "^0.11.20",
191
191
  "@cloudflare/workers-tsconfig": "0.0.0"
192
192
  },
193
193
  "optionalDependencies": {
@@ -755,8 +755,8 @@ attributes?: { name?: string, domain?: string }
755
755
  */
756
756
  declare function deploy({ directory, accountId, projectName, branch, skipCaching, commitMessage, commitHash, commitDirty, functionsDirectory: customFunctionsDirectory, bundle, }: PagesDeployOptions): Promise<{
757
757
  url: string;
758
- environment: "production" | "preview";
759
758
  id: string;
759
+ environment: "production" | "preview";
760
760
  project_id: string;
761
761
  project_name: string;
762
762
  build_config: {
@@ -2597,6 +2597,17 @@ declare interface MultiCacheQueryOptions extends CacheQueryOptions_2 {
2597
2597
  cacheName?: string
2598
2598
  }
2599
2599
 
2600
+ declare interface PagesConfigFields {
2601
+ /**
2602
+ * The directory of static assets to serve.
2603
+ *
2604
+ * The presence of this field in `wrangler.toml` indicates a Pages project,
2605
+ * and will prompt the handling of the configuration file according to the
2606
+ * Pages-specific validation rules.
2607
+ */
2608
+ pages_build_output_dir?: string;
2609
+ }
2610
+
2600
2611
  declare interface PagesDeployOptions {
2601
2612
  /**
2602
2613
  * Path to static assets to deploy to Pages
@@ -23077,7 +23088,7 @@ declare type ProxyWorkerOutgoingRequestBody = {
23077
23088
  args: Parameters<typeof console.debug>;
23078
23089
  };
23079
23090
 
23080
- declare type RawConfig = Partial<ConfigFields<RawDevConfig>> & RawEnvironment & DeprecatedConfigFields & EnvironmentMap;
23091
+ declare type RawConfig = Partial<ConfigFields<RawDevConfig>> & PagesConfigFields & RawEnvironment & DeprecatedConfigFields & EnvironmentMap;
23081
23092
 
23082
23093
  declare type RawDevConfig = Partial<DevConfig>;
23083
23094
 
@@ -118248,6 +118248,14 @@ var JsonFriendlyFatalError = class extends FatalError {
118248
118248
  }
118249
118249
  };
118250
118250
  __name(JsonFriendlyFatalError, "JsonFriendlyFatalError");
118251
+ function createFatalError(message, isJson, code) {
118252
+ if (isJson) {
118253
+ return new JsonFriendlyFatalError(JSON.stringify(message), code);
118254
+ } else {
118255
+ return new FatalError(`${message}`, code);
118256
+ }
118257
+ }
118258
+ __name(createFatalError, "createFatalError");
118251
118259
 
118252
118260
  // src/logger.ts
118253
118261
  init_import_meta_url();
@@ -119644,7 +119652,7 @@ var import_node_assert2 = __toESM(require("node:assert"));
119644
119652
  var import_undici3 = __toESM(require_undici());
119645
119653
 
119646
119654
  // package.json
119647
- var version = "3.34.2";
119655
+ var version = "3.35.0";
119648
119656
  var package_default = {
119649
119657
  name: "wrangler",
119650
119658
  version,
@@ -121764,16 +121772,25 @@ function normalizeAndValidateConfig(rawConfig, configPath, args) {
121764
121772
  rawConfig.keep_vars,
121765
121773
  "boolean"
121766
121774
  );
121775
+ validateOptionalProperty(
121776
+ diagnostics,
121777
+ "",
121778
+ "pages_build_output_dir",
121779
+ rawConfig.pages_build_output_dir,
121780
+ "string"
121781
+ );
121767
121782
  const isLegacyEnv2 = typeof args["legacy-env"] === "boolean" ? args["legacy-env"] : rawConfig.legacy_env ?? true;
121768
121783
  if (!isLegacyEnv2) {
121769
121784
  diagnostics.warnings.push(
121770
121785
  "Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
121771
121786
  );
121772
121787
  }
121788
+ const isDispatchNamespace = typeof args["dispatch-namespace"] === "string" && args["dispatch-namespace"].trim() !== "";
121773
121789
  const topLevelEnv = normalizeAndValidateEnvironment(
121774
121790
  diagnostics,
121775
121791
  configPath,
121776
- rawConfig
121792
+ rawConfig,
121793
+ isDispatchNamespace
121777
121794
  );
121778
121795
  const envName = args.env;
121779
121796
  (0, import_node_assert3.default)(envName === void 0 || typeof envName === "string");
@@ -121788,6 +121805,7 @@ function normalizeAndValidateConfig(rawConfig, configPath, args) {
121788
121805
  envDiagnostics,
121789
121806
  configPath,
121790
121807
  rawEnv,
121808
+ isDispatchNamespace,
121791
121809
  envName,
121792
121810
  topLevelEnv,
121793
121811
  isLegacyEnv2,
@@ -121799,6 +121817,7 @@ function normalizeAndValidateConfig(rawConfig, configPath, args) {
121799
121817
  envDiagnostics,
121800
121818
  configPath,
121801
121819
  {},
121820
+ isDispatchNamespace,
121802
121821
  envName,
121803
121822
  topLevelEnv,
121804
121823
  isLegacyEnv2,
@@ -121823,6 +121842,10 @@ Consider adding an environment configuration section to the wrangler.toml file:
121823
121842
  }
121824
121843
  const config = {
121825
121844
  configPath,
121845
+ pages_build_output_dir: normalizeAndValidatePagesBuildOutputDir(
121846
+ configPath,
121847
+ rawConfig.pages_build_output_dir
121848
+ ),
121826
121849
  legacy_env: isLegacyEnv2,
121827
121850
  send_metrics: rawConfig.send_metrics,
121828
121851
  keep_vars: rawConfig.keep_vars,
@@ -121980,6 +122003,20 @@ function normalizeAndValidateBaseDirField(configPath, rawDir) {
121980
122003
  }
121981
122004
  }
121982
122005
  __name(normalizeAndValidateBaseDirField, "normalizeAndValidateBaseDirField");
122006
+ function normalizeAndValidatePagesBuildOutputDir(configPath, rawPagesDir) {
122007
+ const configDir = import_node_path7.default.dirname(configPath ?? "wrangler.toml");
122008
+ if (rawPagesDir !== void 0) {
122009
+ if (typeof rawPagesDir === "string") {
122010
+ const directory = import_node_path7.default.resolve(configDir);
122011
+ return import_node_path7.default.resolve(directory, rawPagesDir);
122012
+ } else {
122013
+ return rawPagesDir;
122014
+ }
122015
+ } else {
122016
+ return;
122017
+ }
122018
+ }
122019
+ __name(normalizeAndValidatePagesBuildOutputDir, "normalizeAndValidatePagesBuildOutputDir");
121983
122020
  function normalizeAndValidateDev(diagnostics, rawDev, args) {
121984
122021
  (0, import_node_assert3.default)(typeof args === "object" && args !== null && !Array.isArray(args));
121985
122022
  const {
@@ -122430,7 +122467,7 @@ var validateTailConsumers = /* @__PURE__ */ __name((diagnostics, field, value) =
122430
122467
  }
122431
122468
  return isValid;
122432
122469
  }, "validateTailConsumers");
122433
- function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, envName = "top level", topLevelEnv, isLegacyEnv2, rawConfig) {
122470
+ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDispatchNamespace, envName = "top level", topLevelEnv, isLegacyEnv2, rawConfig) {
122434
122471
  deprecated(
122435
122472
  diagnostics,
122436
122473
  rawEnv,
@@ -122534,7 +122571,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, envNam
122534
122571
  topLevelEnv,
122535
122572
  rawEnv,
122536
122573
  "name",
122537
- isValidName,
122574
+ isDispatchNamespace ? isString : isValidName,
122538
122575
  appendEnvName(envName),
122539
122576
  void 0
122540
122577
  ),
@@ -123998,6 +124035,196 @@ function normalizeAndValidateLimits(diagnostics, topLevelEnv, rawEnv) {
123998
124035
  }
123999
124036
  __name(normalizeAndValidateLimits, "normalizeAndValidateLimits");
124000
124037
 
124038
+ // src/config/validation-pages.ts
124039
+ init_import_meta_url();
124040
+
124041
+ // src/config/config.ts
124042
+ init_import_meta_url();
124043
+ var defaultWranglerConfig = {
124044
+ /*====================================================*/
124045
+ /* Fields supported by both Workers & Pages */
124046
+ /*====================================================*/
124047
+ /* TOP-LEVEL ONLY FIELDS */
124048
+ pages_build_output_dir: void 0,
124049
+ send_metrics: void 0,
124050
+ dev: {
124051
+ ip: process.platform === "win32" ? "127.0.0.1" : "localhost",
124052
+ port: void 0,
124053
+ // the default of 8787 is set at runtime
124054
+ inspector_port: void 0,
124055
+ // the default of 9229 is set at runtime
124056
+ local_protocol: "http",
124057
+ upstream_protocol: "http",
124058
+ host: void 0
124059
+ },
124060
+ /** INHERITABLE ENVIRONMENT FIELDS **/
124061
+ name: void 0,
124062
+ compatibility_date: void 0,
124063
+ compatibility_flags: [],
124064
+ limits: void 0,
124065
+ placement: void 0,
124066
+ /** NON-INHERITABLE ENVIRONMENT FIELDS **/
124067
+ vars: {},
124068
+ durable_objects: { bindings: [] },
124069
+ kv_namespaces: [],
124070
+ queues: {
124071
+ producers: [],
124072
+ consumers: []
124073
+ // WORKERS SUPPORT ONLY!!
124074
+ },
124075
+ r2_buckets: [],
124076
+ d1_databases: [],
124077
+ vectorize: [],
124078
+ hyperdrive: [],
124079
+ services: [],
124080
+ analytics_engine_datasets: [],
124081
+ ai: void 0,
124082
+ /*====================================================*/
124083
+ /* Fields supported by Workers only */
124084
+ /*====================================================*/
124085
+ /* TOP-LEVEL ONLY FIELDS */
124086
+ configPath: void 0,
124087
+ legacy_env: true,
124088
+ migrations: [],
124089
+ site: void 0,
124090
+ assets: void 0,
124091
+ wasm_modules: void 0,
124092
+ text_blobs: void 0,
124093
+ data_blobs: void 0,
124094
+ keep_vars: void 0,
124095
+ /** INHERITABLE ENVIRONMENT FIELDS **/
124096
+ account_id: void 0,
124097
+ main: void 0,
124098
+ find_additional_modules: void 0,
124099
+ preserve_file_names: void 0,
124100
+ base_dir: void 0,
124101
+ workers_dev: void 0,
124102
+ route: void 0,
124103
+ routes: void 0,
124104
+ tsconfig: void 0,
124105
+ jsx_factory: "React.createElement",
124106
+ jsx_fragment: "React.Fragment",
124107
+ triggers: {
124108
+ crons: []
124109
+ },
124110
+ usage_model: void 0,
124111
+ rules: [],
124112
+ build: { command: void 0, watch_dir: "./src", cwd: void 0 },
124113
+ no_bundle: void 0,
124114
+ minify: void 0,
124115
+ node_compat: void 0,
124116
+ dispatch_namespaces: [],
124117
+ first_party_worker: void 0,
124118
+ zone_id: void 0,
124119
+ logfwdr: { bindings: [] },
124120
+ logpush: void 0,
124121
+ /** NON-INHERITABLE ENVIRONMENT FIELDS **/
124122
+ define: {},
124123
+ cloudchamber: {},
124124
+ send_email: [],
124125
+ constellation: [],
124126
+ browser: void 0,
124127
+ unsafe: {
124128
+ bindings: void 0,
124129
+ metadata: void 0
124130
+ },
124131
+ mtls_certificates: [],
124132
+ tail_consumers: void 0
124133
+ };
124134
+
124135
+ // src/config/validation-pages.ts
124136
+ var supportedPagesConfigFields = [
124137
+ "pages_build_output_dir",
124138
+ "name",
124139
+ "compatibility_date",
124140
+ "compatibility_flags",
124141
+ "send_metrics",
124142
+ "limits",
124143
+ "placement",
124144
+ "vars",
124145
+ "durable_objects",
124146
+ "kv_namespaces",
124147
+ "queues",
124148
+ // `producers` ONLY
124149
+ "r2_buckets",
124150
+ "d1_databases",
124151
+ "vectorize",
124152
+ "hyperdrive",
124153
+ "services",
124154
+ "analytics_engine_datasets",
124155
+ "ai",
124156
+ "dev",
124157
+ // normalizeAndValidateConfig() sets this value
124158
+ "configPath"
124159
+ ];
124160
+ function validatePagesConfig(config, envNames) {
124161
+ if (!config.pages_build_output_dir) {
124162
+ throw new FatalError(`Attempting to validate Pages configuration file, but no "pages_build_output_dir" configuration key was found.
124163
+ "pages_build_output_dir" is required for Pages projects.`);
124164
+ }
124165
+ const diagnostics = new Diagnostics(
124166
+ `Running configuration file validation for Pages:`
124167
+ );
124168
+ validateMainField(config, diagnostics);
124169
+ validatePagesEnvironmentNames(envNames, diagnostics);
124170
+ validateUnsupportedFields(config, diagnostics);
124171
+ return diagnostics;
124172
+ }
124173
+ __name(validatePagesConfig, "validatePagesConfig");
124174
+ function validateMainField(config, diagnostics) {
124175
+ if (config.main !== void 0) {
124176
+ diagnostics.errors.push(
124177
+ `Configuration file cannot contain both both "main" and "pages_build_output_dir" configuration keys.
124178
+ Please use "main" if you are deploying a Worker, or "pages_build_output_dir" if you are deploying a Pages project.`
124179
+ );
124180
+ }
124181
+ }
124182
+ __name(validateMainField, "validateMainField");
124183
+ function validatePagesEnvironmentNames(envNames, diagnostics) {
124184
+ if (!envNames?.length)
124185
+ return;
124186
+ const unsupportedPagesEnvNames = envNames.filter(
124187
+ (name) => name !== "preview" && name !== "production"
124188
+ );
124189
+ if (unsupportedPagesEnvNames.length > 0) {
124190
+ diagnostics.errors.push(
124191
+ `Configuration file contains environment names that are not supported by Pages projects:
124192
+ ${unsupportedPagesEnvNames.join()}.
124193
+ The supported named-environments for Pages are "preview" and "production".`
124194
+ );
124195
+ }
124196
+ }
124197
+ __name(validatePagesEnvironmentNames, "validatePagesEnvironmentNames");
124198
+ function validateUnsupportedFields(config, diagnostics) {
124199
+ const unsupportedFields = new Set(Object.keys(config));
124200
+ for (const field of supportedPagesConfigFields) {
124201
+ if (field === "queues" && config.queues?.consumers?.length) {
124202
+ continue;
124203
+ }
124204
+ unsupportedFields.delete(field);
124205
+ }
124206
+ for (const field of unsupportedFields) {
124207
+ if (config[field] === void 0 || JSON.stringify(config[field]) === JSON.stringify(defaultWranglerConfig[field])) {
124208
+ unsupportedFields.delete(field);
124209
+ }
124210
+ }
124211
+ if (unsupportedFields.size > 0) {
124212
+ const fields = Array.from(unsupportedFields.keys());
124213
+ fields.forEach((field) => {
124214
+ if (field === "queues" && config.queues?.consumers?.length) {
124215
+ diagnostics.errors.push(
124216
+ `Configuration file for Pages projects does not support "queues.consumers"`
124217
+ );
124218
+ } else {
124219
+ diagnostics.errors.push(
124220
+ `Configuration file for Pages projects does not support "${field}"`
124221
+ );
124222
+ }
124223
+ });
124224
+ }
124225
+ }
124226
+ __name(validateUnsupportedFields, "validateUnsupportedFields");
124227
+
124001
124228
  // src/config/index.ts
124002
124229
  function readConfig(configPath, args) {
124003
124230
  let rawConfig = {};
@@ -124009,6 +124236,12 @@ function readConfig(configPath, args) {
124009
124236
  } else if (configPath?.endsWith("json")) {
124010
124237
  rawConfig = parseJSONC(readFileSync5(configPath), configPath);
124011
124238
  }
124239
+ const isPagesConfig = rawConfig.pages_build_output_dir !== void 0;
124240
+ if (isPagesConfig && (configPath?.endsWith("json") || args.experimentalJsonConfig)) {
124241
+ throw new UserError(
124242
+ `Pages doesn't currently support JSON formatted config \`${configPath ?? "wrangler.json"}\`. Please use wrangler.toml instead.`
124243
+ );
124244
+ }
124012
124245
  const { config, diagnostics } = normalizeAndValidateConfig(
124013
124246
  rawConfig,
124014
124247
  configPath,
@@ -124020,6 +124253,19 @@ function readConfig(configPath, args) {
124020
124253
  if (diagnostics.hasErrors()) {
124021
124254
  throw new UserError(diagnostics.renderErrors());
124022
124255
  }
124256
+ if (isPagesConfig) {
124257
+ logger.debug(
124258
+ `Configuration file belonging to \u26A1\uFE0F Pages \u26A1\uFE0F project detected.`
124259
+ );
124260
+ const envNames = rawConfig.env ? Object.keys(rawConfig.env) : [];
124261
+ const pagesDiagnostics = validatePagesConfig(config, envNames);
124262
+ if (pagesDiagnostics.hasWarnings()) {
124263
+ logger.warn(pagesDiagnostics.renderWarnings());
124264
+ }
124265
+ if (pagesDiagnostics.hasErrors()) {
124266
+ throw new UserError(pagesDiagnostics.renderErrors());
124267
+ }
124268
+ }
124023
124269
  const mainModule = "script" in args ? args.script : config.main;
124024
124270
  if (typeof mainModule === "string" && mainModule.endsWith(".py")) {
124025
124271
  config.no_bundle = true;
@@ -128768,6 +129014,7 @@ function createWorkerUploadForm(worker) {
128768
129014
  compatibility_date,
128769
129015
  compatibility_flags,
128770
129016
  keepVars,
129017
+ keepSecrets,
128771
129018
  logpush,
128772
129019
  placement,
128773
129020
  tail_consumers,
@@ -129016,6 +129263,15 @@ function createWorkerUploadForm(worker) {
129016
129263
  })
129017
129264
  );
129018
129265
  }
129266
+ let keep_bindings = void 0;
129267
+ if (keepVars) {
129268
+ keep_bindings ??= [];
129269
+ keep_bindings.push("plain_text", "json");
129270
+ }
129271
+ if (keepSecrets) {
129272
+ keep_bindings ??= [];
129273
+ keep_bindings.push("secret_text", "secret_key");
129274
+ }
129019
129275
  const metadata = {
129020
129276
  ...main2.type !== "commonjs" ? { main_module: main2.name } : { body_part: main2.name },
129021
129277
  bindings: metadataBindings,
@@ -129024,7 +129280,7 @@ function createWorkerUploadForm(worker) {
129024
129280
  ...usage_model && { usage_model },
129025
129281
  ...migrations && { migrations },
129026
129282
  capnp_schema: capnpSchemaOutputFile,
129027
- ...keepVars && { keep_bindings: ["plain_text", "json"] },
129283
+ ...keep_bindings && { keep_bindings },
129028
129284
  ...logpush !== void 0 && { logpush },
129029
129285
  ...placement && { placement },
129030
129286
  ...tail_consumers && { tail_consumers },
@@ -143786,6 +144042,9 @@ function deployOptions(yargs) {
143786
144042
  }).option("old-asset-ttl", {
143787
144043
  describe: "Expire old assets in given seconds rather than immediate deletion.",
143788
144044
  type: "number"
144045
+ }).option("dispatch-namespace", {
144046
+ describe: "Name of a dispatch namespace to deploy the Worker to (Workers for Platforms)",
144047
+ type: "string"
143789
144048
  });
143790
144049
  }
143791
144050
  __name(deployOptions, "deployOptions");
@@ -143870,7 +144129,8 @@ async function deployHandler(args) {
143870
144129
  keepVars: args.keepVars,
143871
144130
  logpush: args.logpush,
143872
144131
  oldAssetTtl: args.oldAssetTtl,
143873
- projectRoot
144132
+ projectRoot,
144133
+ dispatchNamespace: args.dispatchNamespace
143874
144134
  });
143875
144135
  }
143876
144136
  __name(deployHandler, "deployHandler");
@@ -145548,6 +145808,7 @@ function createWorkerBundleFormData(workerBundle) {
145548
145808
  compatibility_flags: void 0,
145549
145809
  usage_model: void 0,
145550
145810
  keepVars: void 0,
145811
+ keepSecrets: void 0,
145551
145812
  logpush: void 0,
145552
145813
  placement: void 0,
145553
145814
  tail_consumers: void 0,
@@ -147064,6 +147325,27 @@ We looked for the Functions directory (${(0, import_node_path39.basename)(
147064
147325
  };
147065
147326
  }, "validateArgs");
147066
147327
 
147328
+ // src/pages/build-env.ts
147329
+ init_import_meta_url();
147330
+ function Options8(yargs) {
147331
+ return yargs;
147332
+ }
147333
+ __name(Options8, "Options");
147334
+ var Handler8 = /* @__PURE__ */ __name(async (args) => {
147335
+ const config = readConfig(void 0, {
147336
+ ...args,
147337
+ // eslint-disable-next-line turbo/no-undeclared-env-vars
147338
+ env: process.env.PAGES_ENVIRONMENT
147339
+ });
147340
+ if (!config.pages_build_output_dir) {
147341
+ throw new FatalError("No Pages config file found");
147342
+ }
147343
+ const textVars = Object.fromEntries(
147344
+ Object.entries(config.vars).filter(([_3, v2]) => typeof v2 === "string")
147345
+ );
147346
+ logger.log(JSON.stringify(textVars));
147347
+ }, "Handler");
147348
+
147067
147349
  // src/pages/deploy.tsx
147068
147350
  init_import_meta_url();
147069
147351
  var import_node_child_process4 = require("node:child_process");
@@ -147570,15 +147852,15 @@ var import_node_path40 = require("node:path");
147570
147852
  var import_mime2 = __toESM(require_mime2());
147571
147853
  var import_minimatch = __toESM(require_minimatch());
147572
147854
  init_hash();
147573
- function Options8(yargs) {
147855
+ function Options9(yargs) {
147574
147856
  return yargs.positional("directory", {
147575
147857
  type: "string",
147576
147858
  demandOption: true,
147577
147859
  description: "The directory of static files to validate"
147578
147860
  });
147579
147861
  }
147580
- __name(Options8, "Options");
147581
- var Handler8 = /* @__PURE__ */ __name(async ({ directory }) => {
147862
+ __name(Options9, "Options");
147863
+ var Handler9 = /* @__PURE__ */ __name(async ({ directory }) => {
147582
147864
  if (!directory) {
147583
147865
  throw new FatalError("Must specify a directory.", 1);
147584
147866
  }
@@ -147651,7 +147933,7 @@ ${name} is ${prettyBytes(filestat.size, {
147651
147933
  }, "validate");
147652
147934
 
147653
147935
  // src/pages/upload.tsx
147654
- function Options9(yargs) {
147936
+ function Options10(yargs) {
147655
147937
  return yargs.positional("directory", {
147656
147938
  type: "string",
147657
147939
  demandOption: true,
@@ -147667,8 +147949,8 @@ function Options9(yargs) {
147667
147949
  }
147668
147950
  });
147669
147951
  }
147670
- __name(Options9, "Options");
147671
- var Handler9 = /* @__PURE__ */ __name(async ({
147952
+ __name(Options10, "Options");
147953
+ var Handler10 = /* @__PURE__ */ __name(async ({
147672
147954
  directory,
147673
147955
  outputManifestPath,
147674
147956
  skipCaching
@@ -148485,7 +148767,7 @@ async function promptSelectProject({
148485
148767
  __name(promptSelectProject, "promptSelectProject");
148486
148768
 
148487
148769
  // src/pages/deploy.tsx
148488
- function Options10(yargs) {
148770
+ function Options11(yargs) {
148489
148771
  return yargs.positional("directory", {
148490
148772
  type: "string",
148491
148773
  demandOption: true,
@@ -148532,8 +148814,8 @@ function Options10(yargs) {
148532
148814
  }
148533
148815
  });
148534
148816
  }
148535
- __name(Options10, "Options");
148536
- var Handler10 = /* @__PURE__ */ __name(async ({
148817
+ __name(Options11, "Options");
148818
+ var Handler11 = /* @__PURE__ */ __name(async ({
148537
148819
  _: _3,
148538
148820
  directory,
148539
148821
  projectName,
@@ -149022,7 +149304,7 @@ __name(createTail, "createTail");
149022
149304
  // src/pages/deployment-tails.ts
149023
149305
  var statusChoices = ["ok", "error", "canceled"];
149024
149306
  var isStatusChoiceList = /* @__PURE__ */ __name((data) => data?.every((d2) => statusChoices.includes(d2)) ?? false, "isStatusChoiceList");
149025
- function Options11(yargs) {
149307
+ function Options12(yargs) {
149026
149308
  return yargs.positional("deployment", {
149027
149309
  type: "string",
149028
149310
  description: "(Optional) ID or URL of the deployment to tail. Specify by environment if deployment ID is unknown."
@@ -149073,8 +149355,8 @@ function Options11(yargs) {
149073
149355
  array: true
149074
149356
  });
149075
149357
  }
149076
- __name(Options11, "Options");
149077
- async function Handler11({
149358
+ __name(Options12, "Options");
149359
+ async function Handler12({
149078
149360
  deployment,
149079
149361
  projectName,
149080
149362
  environment,
@@ -149218,7 +149500,7 @@ async function Handler11({
149218
149500
  logger.log(`Connected to deployment ${deploymentId}, waiting for logs...`);
149219
149501
  }
149220
149502
  }
149221
- __name(Handler11, "Handler");
149503
+ __name(Handler12, "Handler");
149222
149504
 
149223
149505
  // src/pages/deployments.tsx
149224
149506
  init_import_meta_url();
@@ -149315,7 +149597,7 @@ var BINDING_REGEXP = new RegExp(/^(?<binding>[^=]+)(?:=(?<ref>[^\s]+))?$/);
149315
149597
  var SERVICE_BINDING_REGEXP = new RegExp(
149316
149598
  /^(?<binding>[^=]+)=(?<service>[^@\s]+)(@(?<environment>.*)$)?$/
149317
149599
  );
149318
- function Options12(yargs) {
149600
+ function Options13(yargs) {
149319
149601
  return yargs.positional("directory", {
149320
149602
  type: "string",
149321
149603
  demandOption: void 0,
@@ -149461,8 +149743,8 @@ function Options12(yargs) {
149461
149743
  }
149462
149744
  });
149463
149745
  }
149464
- __name(Options12, "Options");
149465
- var Handler12 = /* @__PURE__ */ __name(async ({
149746
+ __name(Options13, "Options");
149747
+ var Handler13 = /* @__PURE__ */ __name(async ({
149466
149748
  directory,
149467
149749
  compatibilityDate,
149468
149750
  compatibilityFlags,
@@ -150076,8 +150358,8 @@ function pages(yargs) {
150076
150358
  return yargs.command(
150077
150359
  "dev [directory] [-- command..]",
150078
150360
  "\u{1F9D1}\u200D\u{1F4BB} Develop your full-stack Pages application locally",
150079
- Options12,
150080
- Handler12
150361
+ Options13,
150362
+ Handler13
150081
150363
  ).command(
150082
150364
  "functions",
150083
150365
  false,
@@ -150086,6 +150368,11 @@ function pages(yargs) {
150086
150368
  "Compile a folder of Cloudflare Pages Functions into a single Worker",
150087
150369
  Options7,
150088
150370
  Handler7
150371
+ ).command(
150372
+ "build-env",
150373
+ "Render a list of environment variables from the config file",
150374
+ Options8,
150375
+ Handler8
150089
150376
  ).command(
150090
150377
  "optimize-routes [routesPath] [outputRoutesPath]",
150091
150378
  "Consolidate and optimize the route paths declared in _routes.json",
@@ -150110,11 +150397,11 @@ function pages(yargs) {
150110
150397
  "Delete a Cloudflare Pages project",
150111
150398
  DeleteOptions,
150112
150399
  DeleteHandler
150113
- ).command("upload [directory]", false, Options9, Handler9).command(
150400
+ ).command("upload [directory]", false, Options10, Handler10).command(
150114
150401
  "validate [directory]",
150115
150402
  false,
150116
- Options8,
150117
- Handler8
150403
+ Options9,
150404
+ Handler9
150118
150405
  )
150119
150406
  ).command(
150120
150407
  "deployment",
@@ -150127,19 +150414,19 @@ function pages(yargs) {
150127
150414
  ).command(
150128
150415
  "create [directory]",
150129
150416
  "\u{1F199} Publish a directory of static assets as a Pages deployment",
150130
- Options10,
150131
- Handler10
150417
+ Options11,
150418
+ Handler11
150132
150419
  ).command(
150133
150420
  "tail [deployment]",
150134
150421
  "Start a tailing session for a project's deployment and livestream logs from your Functions",
150135
- Options11,
150136
- Handler11
150422
+ Options12,
150423
+ Handler12
150137
150424
  )
150138
150425
  ).command(
150139
150426
  ["deploy [directory]", "publish [directory]"],
150140
150427
  "\u{1F199} Deploy a directory of static assets as a Pages deployment",
150141
- Options10,
150142
- Handler10
150428
+ Options11,
150429
+ Handler11
150143
150430
  );
150144
150431
  }
150145
150432
  __name(pages, "pages");
@@ -151986,6 +152273,8 @@ async function createDraftWorker({
151986
152273
  usage_model: void 0,
151987
152274
  keepVars: false,
151988
152275
  // this doesn't matter since it's a new script anyway
152276
+ keepSecrets: false,
152277
+ // this doesn't matter since it's a new script anyway
151989
152278
  logpush: false,
151990
152279
  placement: void 0,
151991
152280
  tail_consumers: void 0,
@@ -161634,13 +161923,6 @@ async function tailHandler(args) {
161634
161923
  `Successfully created tail, expires at ${expiration.toLocaleString()}`
161635
161924
  );
161636
161925
  }
161637
- (0, import_signal_exit7.default)(async () => {
161638
- tail.terminate();
161639
- await deleteTail();
161640
- await sendMetricsEvent("end log stream", {
161641
- sendMetrics: config.send_metrics
161642
- });
161643
- });
161644
161926
  const printLog = args.format === "pretty" ? prettyPrintLogs : jsonPrintLogs;
161645
161927
  tail.on("message", printLog);
161646
161928
  while (tail.readyState !== tail.OPEN) {
@@ -161663,13 +161945,42 @@ async function tailHandler(args) {
161663
161945
  if (args.format === "pretty") {
161664
161946
  logger.log(`Connected to ${scriptDisplayName}, waiting for logs...`);
161665
161947
  }
161666
- tail.on("close", async () => {
161948
+ const cancelPing = startWebSocketPing();
161949
+ tail.on("close", exit6);
161950
+ (0, import_signal_exit7.default)(exit6);
161951
+ async function exit6() {
161952
+ cancelPing();
161667
161953
  tail.terminate();
161668
161954
  await deleteTail();
161669
161955
  await sendMetricsEvent("end log stream", {
161670
161956
  sendMetrics: config.send_metrics
161671
161957
  });
161672
- });
161958
+ }
161959
+ __name(exit6, "exit");
161960
+ function startWebSocketPing() {
161961
+ const PING_MESSAGE = Buffer.from("wrangler tail ping");
161962
+ const PING_INTERVAL = 1e4;
161963
+ let waitingForPong = false;
161964
+ const pingInterval = setInterval(() => {
161965
+ if (waitingForPong) {
161966
+ console.log(args.format);
161967
+ throw createFatalError(
161968
+ "Tail disconnected, exiting.",
161969
+ args.format === "json",
161970
+ 1
161971
+ );
161972
+ }
161973
+ waitingForPong = true;
161974
+ tail.ping(PING_MESSAGE);
161975
+ }, PING_INTERVAL);
161976
+ tail.on("pong", (data) => {
161977
+ if (data.equals(PING_MESSAGE)) {
161978
+ waitingForPong = false;
161979
+ }
161980
+ });
161981
+ return () => clearInterval(pingInterval);
161982
+ }
161983
+ __name(startWebSocketPing, "startWebSocketPing");
161673
161984
  }
161674
161985
  __name(tailHandler, "tailHandler");
161675
161986
 
@@ -163276,6 +163587,9 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
163276
163587
  compatibility_flags: compatibilityFlags,
163277
163588
  usage_model: config.usage_model,
163278
163589
  keepVars: false,
163590
+ // the wrangler.toml should be the source-of-truth for vars
163591
+ keepSecrets: true,
163592
+ // until wrangler.toml specifies secret bindings, we need to inherit from the previous Worker Version
163279
163593
  logpush: void 0,
163280
163594
  placement,
163281
163595
  tail_consumers: config.tail_consumers,
@@ -164370,6 +164684,9 @@ function createCLIParser(argv) {
164370
164684
  } else {
164371
164685
  logger.log(version);
164372
164686
  }
164687
+ logger.warn(
164688
+ "`wrangler version` is deprecated and will be removed in a future major version. Please use `wrangler --version` instead."
164689
+ );
164373
164690
  }
164374
164691
  );
164375
164692
  if (experimentalGradualRollouts) {
@@ -165840,7 +166157,7 @@ Update them to point to this script instead?`;
165840
166157
  __name(publishCustomDomains, "publishCustomDomains");
165841
166158
  async function deploy(props) {
165842
166159
  const { config, accountId, name } = props;
165843
- if (accountId && name) {
166160
+ if (!props.dispatchNamespace && accountId && name) {
165844
166161
  try {
165845
166162
  const serviceMetaData = await fetchResult(
165846
166163
  `/accounts/${accountId}/workers/services/${name}`
@@ -165948,7 +166265,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
165948
166265
  const start = Date.now();
165949
166266
  const notProd = Boolean(!props.legacyEnv && props.env);
165950
166267
  const workerName = notProd ? `${scriptName} (${envName})` : scriptName;
165951
- const workerUrl = notProd ? `/accounts/${accountId}/workers/services/${scriptName}/environments/${envName}` : `/accounts/${accountId}/workers/scripts/${scriptName}`;
166268
+ const workerUrl = props.dispatchNamespace ? `/accounts/${accountId}/workers/dispatch/namespaces/${props.dispatchNamespace}/scripts/${scriptName}` : notProd ? `/accounts/${accountId}/workers/services/${scriptName}/environments/${envName}` : `/accounts/${accountId}/workers/scripts/${scriptName}`;
165952
166269
  let available_on_subdomain = void 0;
165953
166270
  let deploymentId = null;
165954
166271
  const { format: format9 } = props.entry;
@@ -166122,6 +166439,8 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
166122
166439
  compatibility_flags: compatibilityFlags,
166123
166440
  usage_model: config.usage_model,
166124
166441
  keepVars,
166442
+ keepSecrets: keepVars,
166443
+ // keepVars implies keepSecrets
166125
166444
  logpush: props.logpush !== void 0 ? props.logpush : config.logpush,
166126
166445
  placement,
166127
166446
  tail_consumers: config.tail_consumers,
@@ -166219,6 +166538,11 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
166219
166538
  (0, import_node_assert17.default)(accountId, "Missing accountId");
166220
166539
  const uploadMs = Date.now() - start;
166221
166540
  const deployments2 = [];
166541
+ logger.log("Uploaded", workerName, formatTime3(uploadMs));
166542
+ if (props.dispatchNamespace !== void 0) {
166543
+ deployWfpUserWorker(props.dispatchNamespace, deploymentId);
166544
+ return;
166545
+ }
166222
166546
  if (deployToWorkersDev) {
166223
166547
  const userSubdomain = await getWorkersDevSubdomain(accountId);
166224
166548
  const scriptURL = props.legacyEnv || !props.env ? `${scriptName}.${userSubdomain}.workers.dev` : `${envName}.${scriptName}.${userSubdomain}.workers.dev`;
@@ -166287,7 +166611,6 @@ ${dashLink}`);
166287
166611
  }
166288
166612
  }
166289
166613
  }
166290
- logger.log("Uploaded", workerName, formatTime3(uploadMs));
166291
166614
  if (routesOnly.length > 0) {
166292
166615
  deployments2.push(
166293
166616
  publishRoutes(routesOnly, { workerUrl, scriptName, notProd }).then(() => {
@@ -166334,6 +166657,11 @@ ${dashLink}`);
166334
166657
  logger.log("Current Deployment ID:", deploymentId);
166335
166658
  }
166336
166659
  __name(deploy, "deploy");
166660
+ function deployWfpUserWorker(dispatchNamespace, deploymentId) {
166661
+ logger.log(" Dispatch Namespace:", dispatchNamespace);
166662
+ logger.log("Current Deployment ID:", deploymentId);
166663
+ }
166664
+ __name(deployWfpUserWorker, "deployWfpUserWorker");
166337
166665
  function helpIfErrorIsSizeOrScriptStartup2(err, dependencies) {
166338
166666
  if (errIsScriptSize2(err)) {
166339
166667
  printOffendingDependencies(dependencies);
@@ -167493,6 +167821,7 @@ async function createRemoteWorkerInit(props) {
167493
167821
  compatibility_flags: props.compatibilityFlags,
167494
167822
  usage_model: props.usageModel,
167495
167823
  keepVars: true,
167824
+ keepSecrets: true,
167496
167825
  logpush: false,
167497
167826
  placement: void 0,
167498
167827
  // no placement in dev