wrangler 3.34.2 → 3.36.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.36.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,28 @@ 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
+
2611
+ declare interface PagesConfigFields {
2612
+ /**
2613
+ * The directory of static assets to serve.
2614
+ *
2615
+ * The presence of this field in `wrangler.toml` indicates a Pages project,
2616
+ * and will prompt the handling of the configuration file according to the
2617
+ * Pages-specific validation rules.
2618
+ */
2619
+ pages_build_output_dir?: string;
2620
+ }
2621
+
2600
2622
  declare interface PagesDeployOptions {
2601
2623
  /**
2602
2624
  * Path to static assets to deploy to Pages
@@ -23077,7 +23099,7 @@ declare type ProxyWorkerOutgoingRequestBody = {
23077
23099
  args: Parameters<typeof console.debug>;
23078
23100
  };
23079
23101
 
23080
- declare type RawConfig = Partial<ConfigFields<RawDevConfig>> & RawEnvironment & DeprecatedConfigFields & EnvironmentMap;
23102
+ declare type RawConfig = Partial<ConfigFields<RawDevConfig>> & PagesConfigFields & RawEnvironment & DeprecatedConfigFields & EnvironmentMap;
23081
23103
 
23082
23104
  declare type RawDevConfig = Partial<DevConfig>;
23083
23105
 
@@ -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.36.0";
119648
119656
  var package_default = {
119649
119657
  name: "wrangler",
119650
119658
  version,
@@ -120742,6 +120750,8 @@ async function login(props = { browser: true }) {
120742
120750
  __name(finish, "finish");
120743
120751
  (0, import_node_assert.default)(req.url, "This request doesn't have a URL");
120744
120752
  const { pathname, query } = import_node_url3.default.parse(req.url, true);
120753
+ if (req.method !== "GET")
120754
+ return res.end("OK");
120745
120755
  switch (pathname) {
120746
120756
  case "/oauth/callback": {
120747
120757
  let hasAuthCode = false;
@@ -121715,6 +121725,10 @@ var isRecord = /* @__PURE__ */ __name((value) => typeof value === "object" && va
121715
121725
 
121716
121726
  // src/config/validation.ts
121717
121727
  var ENGLISH = new Intl.ListFormat("en");
121728
+ function isPagesConfig(rawConfig) {
121729
+ return rawConfig.pages_build_output_dir !== void 0;
121730
+ }
121731
+ __name(isPagesConfig, "isPagesConfig");
121718
121732
  function normalizeAndValidateConfig(rawConfig, configPath, args) {
121719
121733
  const diagnostics = new Diagnostics(
121720
121734
  `Processing ${configPath ? import_node_path7.default.relative(process.cwd(), configPath) : "wrangler"} configuration:`
@@ -121764,16 +121778,25 @@ function normalizeAndValidateConfig(rawConfig, configPath, args) {
121764
121778
  rawConfig.keep_vars,
121765
121779
  "boolean"
121766
121780
  );
121781
+ validateOptionalProperty(
121782
+ diagnostics,
121783
+ "",
121784
+ "pages_build_output_dir",
121785
+ rawConfig.pages_build_output_dir,
121786
+ "string"
121787
+ );
121767
121788
  const isLegacyEnv2 = typeof args["legacy-env"] === "boolean" ? args["legacy-env"] : rawConfig.legacy_env ?? true;
121768
121789
  if (!isLegacyEnv2) {
121769
121790
  diagnostics.warnings.push(
121770
121791
  "Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
121771
121792
  );
121772
121793
  }
121794
+ const isDispatchNamespace = typeof args["dispatch-namespace"] === "string" && args["dispatch-namespace"].trim() !== "";
121773
121795
  const topLevelEnv = normalizeAndValidateEnvironment(
121774
121796
  diagnostics,
121775
121797
  configPath,
121776
- rawConfig
121798
+ rawConfig,
121799
+ isDispatchNamespace
121777
121800
  );
121778
121801
  const envName = args.env;
121779
121802
  (0, import_node_assert3.default)(envName === void 0 || typeof envName === "string");
@@ -121788,17 +121811,19 @@ function normalizeAndValidateConfig(rawConfig, configPath, args) {
121788
121811
  envDiagnostics,
121789
121812
  configPath,
121790
121813
  rawEnv,
121814
+ isDispatchNamespace,
121791
121815
  envName,
121792
121816
  topLevelEnv,
121793
121817
  isLegacyEnv2,
121794
121818
  rawConfig
121795
121819
  );
121796
121820
  diagnostics.addChild(envDiagnostics);
121797
- } else {
121821
+ } else if (!isPagesConfig(rawConfig)) {
121798
121822
  activeEnv = normalizeAndValidateEnvironment(
121799
121823
  envDiagnostics,
121800
121824
  configPath,
121801
121825
  {},
121826
+ isDispatchNamespace,
121802
121827
  envName,
121803
121828
  topLevelEnv,
121804
121829
  isLegacyEnv2,
@@ -121823,6 +121848,10 @@ Consider adding an environment configuration section to the wrangler.toml file:
121823
121848
  }
121824
121849
  const config = {
121825
121850
  configPath,
121851
+ pages_build_output_dir: normalizeAndValidatePagesBuildOutputDir(
121852
+ configPath,
121853
+ rawConfig.pages_build_output_dir
121854
+ ),
121826
121855
  legacy_env: isLegacyEnv2,
121827
121856
  send_metrics: rawConfig.send_metrics,
121828
121857
  keep_vars: rawConfig.keep_vars,
@@ -121980,6 +122009,20 @@ function normalizeAndValidateBaseDirField(configPath, rawDir) {
121980
122009
  }
121981
122010
  }
121982
122011
  __name(normalizeAndValidateBaseDirField, "normalizeAndValidateBaseDirField");
122012
+ function normalizeAndValidatePagesBuildOutputDir(configPath, rawPagesDir) {
122013
+ const configDir = import_node_path7.default.dirname(configPath ?? "wrangler.toml");
122014
+ if (rawPagesDir !== void 0) {
122015
+ if (typeof rawPagesDir === "string") {
122016
+ const directory = import_node_path7.default.resolve(configDir);
122017
+ return import_node_path7.default.resolve(directory, rawPagesDir);
122018
+ } else {
122019
+ return rawPagesDir;
122020
+ }
122021
+ } else {
122022
+ return;
122023
+ }
122024
+ }
122025
+ __name(normalizeAndValidatePagesBuildOutputDir, "normalizeAndValidatePagesBuildOutputDir");
121983
122026
  function normalizeAndValidateDev(diagnostics, rawDev, args) {
121984
122027
  (0, import_node_assert3.default)(typeof args === "object" && args !== null && !Array.isArray(args));
121985
122028
  const {
@@ -122430,7 +122473,7 @@ var validateTailConsumers = /* @__PURE__ */ __name((diagnostics, field, value) =
122430
122473
  }
122431
122474
  return isValid;
122432
122475
  }, "validateTailConsumers");
122433
- function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, envName = "top level", topLevelEnv, isLegacyEnv2, rawConfig) {
122476
+ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDispatchNamespace, envName = "top level", topLevelEnv, isLegacyEnv2, rawConfig) {
122434
122477
  deprecated(
122435
122478
  diagnostics,
122436
122479
  rawEnv,
@@ -122534,7 +122577,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, envNam
122534
122577
  topLevelEnv,
122535
122578
  rawEnv,
122536
122579
  "name",
122537
- isValidName,
122580
+ isDispatchNamespace ? isString : isValidName,
122538
122581
  appendEnvName(envName),
122539
122582
  void 0
122540
122583
  ),
@@ -123998,6 +124041,196 @@ function normalizeAndValidateLimits(diagnostics, topLevelEnv, rawEnv) {
123998
124041
  }
123999
124042
  __name(normalizeAndValidateLimits, "normalizeAndValidateLimits");
124000
124043
 
124044
+ // src/config/validation-pages.ts
124045
+ init_import_meta_url();
124046
+
124047
+ // src/config/config.ts
124048
+ init_import_meta_url();
124049
+ var defaultWranglerConfig = {
124050
+ /*====================================================*/
124051
+ /* Fields supported by both Workers & Pages */
124052
+ /*====================================================*/
124053
+ /* TOP-LEVEL ONLY FIELDS */
124054
+ pages_build_output_dir: void 0,
124055
+ send_metrics: void 0,
124056
+ dev: {
124057
+ ip: process.platform === "win32" ? "127.0.0.1" : "localhost",
124058
+ port: void 0,
124059
+ // the default of 8787 is set at runtime
124060
+ inspector_port: void 0,
124061
+ // the default of 9229 is set at runtime
124062
+ local_protocol: "http",
124063
+ upstream_protocol: "http",
124064
+ host: void 0
124065
+ },
124066
+ /** INHERITABLE ENVIRONMENT FIELDS **/
124067
+ name: void 0,
124068
+ compatibility_date: void 0,
124069
+ compatibility_flags: [],
124070
+ limits: void 0,
124071
+ placement: void 0,
124072
+ /** NON-INHERITABLE ENVIRONMENT FIELDS **/
124073
+ vars: {},
124074
+ durable_objects: { bindings: [] },
124075
+ kv_namespaces: [],
124076
+ queues: {
124077
+ producers: [],
124078
+ consumers: []
124079
+ // WORKERS SUPPORT ONLY!!
124080
+ },
124081
+ r2_buckets: [],
124082
+ d1_databases: [],
124083
+ vectorize: [],
124084
+ hyperdrive: [],
124085
+ services: [],
124086
+ analytics_engine_datasets: [],
124087
+ ai: void 0,
124088
+ /*====================================================*/
124089
+ /* Fields supported by Workers only */
124090
+ /*====================================================*/
124091
+ /* TOP-LEVEL ONLY FIELDS */
124092
+ configPath: void 0,
124093
+ legacy_env: true,
124094
+ migrations: [],
124095
+ site: void 0,
124096
+ assets: void 0,
124097
+ wasm_modules: void 0,
124098
+ text_blobs: void 0,
124099
+ data_blobs: void 0,
124100
+ keep_vars: void 0,
124101
+ /** INHERITABLE ENVIRONMENT FIELDS **/
124102
+ account_id: void 0,
124103
+ main: void 0,
124104
+ find_additional_modules: void 0,
124105
+ preserve_file_names: void 0,
124106
+ base_dir: void 0,
124107
+ workers_dev: void 0,
124108
+ route: void 0,
124109
+ routes: void 0,
124110
+ tsconfig: void 0,
124111
+ jsx_factory: "React.createElement",
124112
+ jsx_fragment: "React.Fragment",
124113
+ triggers: {
124114
+ crons: []
124115
+ },
124116
+ usage_model: void 0,
124117
+ rules: [],
124118
+ build: { command: void 0, watch_dir: "./src", cwd: void 0 },
124119
+ no_bundle: void 0,
124120
+ minify: void 0,
124121
+ node_compat: void 0,
124122
+ dispatch_namespaces: [],
124123
+ first_party_worker: void 0,
124124
+ zone_id: void 0,
124125
+ logfwdr: { bindings: [] },
124126
+ logpush: void 0,
124127
+ /** NON-INHERITABLE ENVIRONMENT FIELDS **/
124128
+ define: {},
124129
+ cloudchamber: {},
124130
+ send_email: [],
124131
+ constellation: [],
124132
+ browser: void 0,
124133
+ unsafe: {
124134
+ bindings: void 0,
124135
+ metadata: void 0
124136
+ },
124137
+ mtls_certificates: [],
124138
+ tail_consumers: void 0
124139
+ };
124140
+
124141
+ // src/config/validation-pages.ts
124142
+ var supportedPagesConfigFields = [
124143
+ "pages_build_output_dir",
124144
+ "name",
124145
+ "compatibility_date",
124146
+ "compatibility_flags",
124147
+ "send_metrics",
124148
+ "limits",
124149
+ "placement",
124150
+ "vars",
124151
+ "durable_objects",
124152
+ "kv_namespaces",
124153
+ "queues",
124154
+ // `producers` ONLY
124155
+ "r2_buckets",
124156
+ "d1_databases",
124157
+ "vectorize",
124158
+ "hyperdrive",
124159
+ "services",
124160
+ "analytics_engine_datasets",
124161
+ "ai",
124162
+ "dev",
124163
+ // normalizeAndValidateConfig() sets this value
124164
+ "configPath"
124165
+ ];
124166
+ function validatePagesConfig(config, envNames) {
124167
+ if (!config.pages_build_output_dir) {
124168
+ throw new FatalError(`Attempting to validate Pages configuration file, but no "pages_build_output_dir" configuration key was found.
124169
+ "pages_build_output_dir" is required for Pages projects.`);
124170
+ }
124171
+ const diagnostics = new Diagnostics(
124172
+ `Running configuration file validation for Pages:`
124173
+ );
124174
+ validateMainField(config, diagnostics);
124175
+ validatePagesEnvironmentNames(envNames, diagnostics);
124176
+ validateUnsupportedFields(config, diagnostics);
124177
+ return diagnostics;
124178
+ }
124179
+ __name(validatePagesConfig, "validatePagesConfig");
124180
+ function validateMainField(config, diagnostics) {
124181
+ if (config.main !== void 0) {
124182
+ diagnostics.errors.push(
124183
+ `Configuration file cannot contain both both "main" and "pages_build_output_dir" configuration keys.
124184
+ Please use "main" if you are deploying a Worker, or "pages_build_output_dir" if you are deploying a Pages project.`
124185
+ );
124186
+ }
124187
+ }
124188
+ __name(validateMainField, "validateMainField");
124189
+ function validatePagesEnvironmentNames(envNames, diagnostics) {
124190
+ if (!envNames?.length)
124191
+ return;
124192
+ const unsupportedPagesEnvNames = envNames.filter(
124193
+ (name) => name !== "preview" && name !== "production"
124194
+ );
124195
+ if (unsupportedPagesEnvNames.length > 0) {
124196
+ diagnostics.errors.push(
124197
+ `Configuration file contains environment names that are not supported by Pages projects:
124198
+ ${unsupportedPagesEnvNames.join()}.
124199
+ The supported named-environments for Pages are "preview" and "production".`
124200
+ );
124201
+ }
124202
+ }
124203
+ __name(validatePagesEnvironmentNames, "validatePagesEnvironmentNames");
124204
+ function validateUnsupportedFields(config, diagnostics) {
124205
+ const unsupportedFields = new Set(Object.keys(config));
124206
+ for (const field of supportedPagesConfigFields) {
124207
+ if (field === "queues" && config.queues?.consumers?.length) {
124208
+ continue;
124209
+ }
124210
+ unsupportedFields.delete(field);
124211
+ }
124212
+ for (const field of unsupportedFields) {
124213
+ if (config[field] === void 0 || JSON.stringify(config[field]) === JSON.stringify(defaultWranglerConfig[field])) {
124214
+ unsupportedFields.delete(field);
124215
+ }
124216
+ }
124217
+ if (unsupportedFields.size > 0) {
124218
+ const fields = Array.from(unsupportedFields.keys());
124219
+ fields.forEach((field) => {
124220
+ if (field === "queues" && config.queues?.consumers?.length) {
124221
+ diagnostics.errors.push(
124222
+ `Configuration file for Pages projects does not support "queues.consumers"`
124223
+ );
124224
+ } else {
124225
+ diagnostics.errors.push(
124226
+ `Configuration file for Pages projects does not support "${field}"`
124227
+ );
124228
+ }
124229
+ });
124230
+ }
124231
+ }
124232
+ __name(validateUnsupportedFields, "validateUnsupportedFields");
124233
+
124001
124234
  // src/config/index.ts
124002
124235
  function readConfig(configPath, args) {
124003
124236
  let rawConfig = {};
@@ -124009,6 +124242,12 @@ function readConfig(configPath, args) {
124009
124242
  } else if (configPath?.endsWith("json")) {
124010
124243
  rawConfig = parseJSONC(readFileSync5(configPath), configPath);
124011
124244
  }
124245
+ const isPagesConfig2 = rawConfig.pages_build_output_dir !== void 0;
124246
+ if (isPagesConfig2 && (configPath?.endsWith("json") || args.experimentalJsonConfig)) {
124247
+ throw new UserError(
124248
+ `Pages doesn't currently support JSON formatted config \`${configPath ?? "wrangler.json"}\`. Please use wrangler.toml instead.`
124249
+ );
124250
+ }
124012
124251
  const { config, diagnostics } = normalizeAndValidateConfig(
124013
124252
  rawConfig,
124014
124253
  configPath,
@@ -124020,6 +124259,19 @@ function readConfig(configPath, args) {
124020
124259
  if (diagnostics.hasErrors()) {
124021
124260
  throw new UserError(diagnostics.renderErrors());
124022
124261
  }
124262
+ if (isPagesConfig2) {
124263
+ logger.debug(
124264
+ `Configuration file belonging to \u26A1\uFE0F Pages \u26A1\uFE0F project detected.`
124265
+ );
124266
+ const envNames = rawConfig.env ? Object.keys(rawConfig.env) : [];
124267
+ const pagesDiagnostics = validatePagesConfig(config, envNames);
124268
+ if (pagesDiagnostics.hasWarnings()) {
124269
+ logger.warn(pagesDiagnostics.renderWarnings());
124270
+ }
124271
+ if (pagesDiagnostics.hasErrors()) {
124272
+ throw new UserError(pagesDiagnostics.renderErrors());
124273
+ }
124274
+ }
124023
124275
  const mainModule = "script" in args ? args.script : config.main;
124024
124276
  if (typeof mainModule === "string" && mainModule.endsWith(".py")) {
124025
124277
  config.no_bundle = true;
@@ -128768,6 +129020,7 @@ function createWorkerUploadForm(worker) {
128768
129020
  compatibility_date,
128769
129021
  compatibility_flags,
128770
129022
  keepVars,
129023
+ keepSecrets,
128771
129024
  logpush,
128772
129025
  placement,
128773
129026
  tail_consumers,
@@ -129016,6 +129269,15 @@ function createWorkerUploadForm(worker) {
129016
129269
  })
129017
129270
  );
129018
129271
  }
129272
+ let keep_bindings = void 0;
129273
+ if (keepVars) {
129274
+ keep_bindings ??= [];
129275
+ keep_bindings.push("plain_text", "json");
129276
+ }
129277
+ if (keepSecrets) {
129278
+ keep_bindings ??= [];
129279
+ keep_bindings.push("secret_text", "secret_key");
129280
+ }
129019
129281
  const metadata = {
129020
129282
  ...main2.type !== "commonjs" ? { main_module: main2.name } : { body_part: main2.name },
129021
129283
  bindings: metadataBindings,
@@ -129024,7 +129286,7 @@ function createWorkerUploadForm(worker) {
129024
129286
  ...usage_model && { usage_model },
129025
129287
  ...migrations && { migrations },
129026
129288
  capnp_schema: capnpSchemaOutputFile,
129027
- ...keepVars && { keep_bindings: ["plain_text", "json"] },
129289
+ ...keep_bindings && { keep_bindings },
129028
129290
  ...logpush !== void 0 && { logpush },
129029
129291
  ...placement && { placement },
129030
129292
  ...tail_consumers && { tail_consumers },
@@ -143786,6 +144048,9 @@ function deployOptions(yargs) {
143786
144048
  }).option("old-asset-ttl", {
143787
144049
  describe: "Expire old assets in given seconds rather than immediate deletion.",
143788
144050
  type: "number"
144051
+ }).option("dispatch-namespace", {
144052
+ describe: "Name of a dispatch namespace to deploy the Worker to (Workers for Platforms)",
144053
+ type: "string"
143789
144054
  });
143790
144055
  }
143791
144056
  __name(deployOptions, "deployOptions");
@@ -143870,7 +144135,8 @@ async function deployHandler(args) {
143870
144135
  keepVars: args.keepVars,
143871
144136
  logpush: args.logpush,
143872
144137
  oldAssetTtl: args.oldAssetTtl,
143873
- projectRoot
144138
+ projectRoot,
144139
+ dispatchNamespace: args.dispatchNamespace
143874
144140
  });
143875
144141
  }
143876
144142
  __name(deployHandler, "deployHandler");
@@ -145548,6 +145814,7 @@ function createWorkerBundleFormData(workerBundle) {
145548
145814
  compatibility_flags: void 0,
145549
145815
  usage_model: void 0,
145550
145816
  keepVars: void 0,
145817
+ keepSecrets: void 0,
145551
145818
  logpush: void 0,
145552
145819
  placement: void 0,
145553
145820
  tail_consumers: void 0,
@@ -147064,6 +147331,27 @@ We looked for the Functions directory (${(0, import_node_path39.basename)(
147064
147331
  };
147065
147332
  }, "validateArgs");
147066
147333
 
147334
+ // src/pages/build-env.ts
147335
+ init_import_meta_url();
147336
+ function Options8(yargs) {
147337
+ return yargs;
147338
+ }
147339
+ __name(Options8, "Options");
147340
+ var Handler8 = /* @__PURE__ */ __name(async (args) => {
147341
+ const config = readConfig(void 0, {
147342
+ ...args,
147343
+ // eslint-disable-next-line turbo/no-undeclared-env-vars
147344
+ env: process.env.PAGES_ENVIRONMENT
147345
+ });
147346
+ if (!config.pages_build_output_dir) {
147347
+ throw new FatalError("No Pages config file found");
147348
+ }
147349
+ const textVars = Object.fromEntries(
147350
+ Object.entries(config.vars).filter(([_3, v2]) => typeof v2 === "string")
147351
+ );
147352
+ logger.log(JSON.stringify(textVars));
147353
+ }, "Handler");
147354
+
147067
147355
  // src/pages/deploy.tsx
147068
147356
  init_import_meta_url();
147069
147357
  var import_node_child_process4 = require("node:child_process");
@@ -147570,15 +147858,15 @@ var import_node_path40 = require("node:path");
147570
147858
  var import_mime2 = __toESM(require_mime2());
147571
147859
  var import_minimatch = __toESM(require_minimatch());
147572
147860
  init_hash();
147573
- function Options8(yargs) {
147861
+ function Options9(yargs) {
147574
147862
  return yargs.positional("directory", {
147575
147863
  type: "string",
147576
147864
  demandOption: true,
147577
147865
  description: "The directory of static files to validate"
147578
147866
  });
147579
147867
  }
147580
- __name(Options8, "Options");
147581
- var Handler8 = /* @__PURE__ */ __name(async ({ directory }) => {
147868
+ __name(Options9, "Options");
147869
+ var Handler9 = /* @__PURE__ */ __name(async ({ directory }) => {
147582
147870
  if (!directory) {
147583
147871
  throw new FatalError("Must specify a directory.", 1);
147584
147872
  }
@@ -147651,7 +147939,7 @@ ${name} is ${prettyBytes(filestat.size, {
147651
147939
  }, "validate");
147652
147940
 
147653
147941
  // src/pages/upload.tsx
147654
- function Options9(yargs) {
147942
+ function Options10(yargs) {
147655
147943
  return yargs.positional("directory", {
147656
147944
  type: "string",
147657
147945
  demandOption: true,
@@ -147667,8 +147955,8 @@ function Options9(yargs) {
147667
147955
  }
147668
147956
  });
147669
147957
  }
147670
- __name(Options9, "Options");
147671
- var Handler9 = /* @__PURE__ */ __name(async ({
147958
+ __name(Options10, "Options");
147959
+ var Handler10 = /* @__PURE__ */ __name(async ({
147672
147960
  directory,
147673
147961
  outputManifestPath,
147674
147962
  skipCaching
@@ -148485,7 +148773,7 @@ async function promptSelectProject({
148485
148773
  __name(promptSelectProject, "promptSelectProject");
148486
148774
 
148487
148775
  // src/pages/deploy.tsx
148488
- function Options10(yargs) {
148776
+ function Options11(yargs) {
148489
148777
  return yargs.positional("directory", {
148490
148778
  type: "string",
148491
148779
  demandOption: true,
@@ -148532,8 +148820,8 @@ function Options10(yargs) {
148532
148820
  }
148533
148821
  });
148534
148822
  }
148535
- __name(Options10, "Options");
148536
- var Handler10 = /* @__PURE__ */ __name(async ({
148823
+ __name(Options11, "Options");
148824
+ var Handler11 = /* @__PURE__ */ __name(async ({
148537
148825
  _: _3,
148538
148826
  directory,
148539
148827
  projectName,
@@ -149022,7 +149310,7 @@ __name(createTail, "createTail");
149022
149310
  // src/pages/deployment-tails.ts
149023
149311
  var statusChoices = ["ok", "error", "canceled"];
149024
149312
  var isStatusChoiceList = /* @__PURE__ */ __name((data) => data?.every((d2) => statusChoices.includes(d2)) ?? false, "isStatusChoiceList");
149025
- function Options11(yargs) {
149313
+ function Options12(yargs) {
149026
149314
  return yargs.positional("deployment", {
149027
149315
  type: "string",
149028
149316
  description: "(Optional) ID or URL of the deployment to tail. Specify by environment if deployment ID is unknown."
@@ -149073,8 +149361,8 @@ function Options11(yargs) {
149073
149361
  array: true
149074
149362
  });
149075
149363
  }
149076
- __name(Options11, "Options");
149077
- async function Handler11({
149364
+ __name(Options12, "Options");
149365
+ async function Handler12({
149078
149366
  deployment,
149079
149367
  projectName,
149080
149368
  environment,
@@ -149218,7 +149506,7 @@ async function Handler11({
149218
149506
  logger.log(`Connected to deployment ${deploymentId}, waiting for logs...`);
149219
149507
  }
149220
149508
  }
149221
- __name(Handler11, "Handler");
149509
+ __name(Handler12, "Handler");
149222
149510
 
149223
149511
  // src/pages/deployments.tsx
149224
149512
  init_import_meta_url();
@@ -149315,7 +149603,7 @@ var BINDING_REGEXP = new RegExp(/^(?<binding>[^=]+)(?:=(?<ref>[^\s]+))?$/);
149315
149603
  var SERVICE_BINDING_REGEXP = new RegExp(
149316
149604
  /^(?<binding>[^=]+)=(?<service>[^@\s]+)(@(?<environment>.*)$)?$/
149317
149605
  );
149318
- function Options12(yargs) {
149606
+ function Options13(yargs) {
149319
149607
  return yargs.positional("directory", {
149320
149608
  type: "string",
149321
149609
  demandOption: void 0,
@@ -149458,11 +149746,15 @@ function Options12(yargs) {
149458
149746
  "log-level": {
149459
149747
  choices: ["debug", "info", "log", "warn", "error", "none"],
149460
149748
  describe: "Specify logging level"
149749
+ },
149750
+ "show-interactive-dev-session": {
149751
+ describe: "Show interactive dev session (defaults to true if the terminal supports interactivity)",
149752
+ type: "boolean"
149461
149753
  }
149462
149754
  });
149463
149755
  }
149464
- __name(Options12, "Options");
149465
- var Handler12 = /* @__PURE__ */ __name(async ({
149756
+ __name(Options13, "Options");
149757
+ var Handler13 = /* @__PURE__ */ __name(async ({
149466
149758
  directory,
149467
149759
  compatibilityDate,
149468
149760
  compatibilityFlags,
@@ -149489,7 +149781,8 @@ var Handler12 = /* @__PURE__ */ __name(async ({
149489
149781
  experimentalLocal,
149490
149782
  config,
149491
149783
  _: [_pages, _dev, ...remaining],
149492
- logLevel
149784
+ logLevel,
149785
+ showInteractiveDevSession
149493
149786
  }) => {
149494
149787
  if (logLevel) {
149495
149788
  logger.loggerLevel = logLevel;
@@ -149881,7 +150174,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates/ for
149881
150174
  },
149882
150175
  liveReload,
149883
150176
  forceLocal: true,
149884
- showInteractiveDevSession: void 0,
150177
+ showInteractiveDevSession,
149885
150178
  testMode: false,
149886
150179
  watch: true
149887
150180
  }
@@ -150076,8 +150369,8 @@ function pages(yargs) {
150076
150369
  return yargs.command(
150077
150370
  "dev [directory] [-- command..]",
150078
150371
  "\u{1F9D1}\u200D\u{1F4BB} Develop your full-stack Pages application locally",
150079
- Options12,
150080
- Handler12
150372
+ Options13,
150373
+ Handler13
150081
150374
  ).command(
150082
150375
  "functions",
150083
150376
  false,
@@ -150086,6 +150379,11 @@ function pages(yargs) {
150086
150379
  "Compile a folder of Cloudflare Pages Functions into a single Worker",
150087
150380
  Options7,
150088
150381
  Handler7
150382
+ ).command(
150383
+ "build-env",
150384
+ "Render a list of environment variables from the config file",
150385
+ Options8,
150386
+ Handler8
150089
150387
  ).command(
150090
150388
  "optimize-routes [routesPath] [outputRoutesPath]",
150091
150389
  "Consolidate and optimize the route paths declared in _routes.json",
@@ -150110,11 +150408,11 @@ function pages(yargs) {
150110
150408
  "Delete a Cloudflare Pages project",
150111
150409
  DeleteOptions,
150112
150410
  DeleteHandler
150113
- ).command("upload [directory]", false, Options9, Handler9).command(
150411
+ ).command("upload [directory]", false, Options10, Handler10).command(
150114
150412
  "validate [directory]",
150115
150413
  false,
150116
- Options8,
150117
- Handler8
150414
+ Options9,
150415
+ Handler9
150118
150416
  )
150119
150417
  ).command(
150120
150418
  "deployment",
@@ -150127,19 +150425,19 @@ function pages(yargs) {
150127
150425
  ).command(
150128
150426
  "create [directory]",
150129
150427
  "\u{1F199} Publish a directory of static assets as a Pages deployment",
150130
- Options10,
150131
- Handler10
150428
+ Options11,
150429
+ Handler11
150132
150430
  ).command(
150133
150431
  "tail [deployment]",
150134
150432
  "Start a tailing session for a project's deployment and livestream logs from your Functions",
150135
- Options11,
150136
- Handler11
150433
+ Options12,
150434
+ Handler12
150137
150435
  )
150138
150436
  ).command(
150139
150437
  ["deploy [directory]", "publish [directory]"],
150140
150438
  "\u{1F199} Deploy a directory of static assets as a Pages deployment",
150141
- Options10,
150142
- Handler10
150439
+ Options11,
150440
+ Handler11
150143
150441
  );
150144
150442
  }
150145
150443
  __name(pages, "pages");
@@ -151986,6 +152284,8 @@ async function createDraftWorker({
151986
152284
  usage_model: void 0,
151987
152285
  keepVars: false,
151988
152286
  // this doesn't matter since it's a new script anyway
152287
+ keepSecrets: false,
152288
+ // this doesn't matter since it's a new script anyway
151989
152289
  logpush: false,
151990
152290
  placement: void 0,
151991
152291
  tail_consumers: void 0,
@@ -161634,13 +161934,6 @@ async function tailHandler(args) {
161634
161934
  `Successfully created tail, expires at ${expiration.toLocaleString()}`
161635
161935
  );
161636
161936
  }
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
161937
  const printLog = args.format === "pretty" ? prettyPrintLogs : jsonPrintLogs;
161645
161938
  tail.on("message", printLog);
161646
161939
  while (tail.readyState !== tail.OPEN) {
@@ -161663,13 +161956,42 @@ async function tailHandler(args) {
161663
161956
  if (args.format === "pretty") {
161664
161957
  logger.log(`Connected to ${scriptDisplayName}, waiting for logs...`);
161665
161958
  }
161666
- tail.on("close", async () => {
161959
+ const cancelPing = startWebSocketPing();
161960
+ tail.on("close", exit6);
161961
+ (0, import_signal_exit7.default)(exit6);
161962
+ async function exit6() {
161963
+ cancelPing();
161667
161964
  tail.terminate();
161668
161965
  await deleteTail();
161669
161966
  await sendMetricsEvent("end log stream", {
161670
161967
  sendMetrics: config.send_metrics
161671
161968
  });
161672
- });
161969
+ }
161970
+ __name(exit6, "exit");
161971
+ function startWebSocketPing() {
161972
+ const PING_MESSAGE = Buffer.from("wrangler tail ping");
161973
+ const PING_INTERVAL = 1e4;
161974
+ let waitingForPong = false;
161975
+ const pingInterval = setInterval(() => {
161976
+ if (waitingForPong) {
161977
+ console.log(args.format);
161978
+ throw createFatalError(
161979
+ "Tail disconnected, exiting.",
161980
+ args.format === "json",
161981
+ 1
161982
+ );
161983
+ }
161984
+ waitingForPong = true;
161985
+ tail.ping(PING_MESSAGE);
161986
+ }, PING_INTERVAL);
161987
+ tail.on("pong", (data) => {
161988
+ if (data.equals(PING_MESSAGE)) {
161989
+ waitingForPong = false;
161990
+ }
161991
+ });
161992
+ return () => clearInterval(pingInterval);
161993
+ }
161994
+ __name(startWebSocketPing, "startWebSocketPing");
161673
161995
  }
161674
161996
  __name(tailHandler, "tailHandler");
161675
161997
 
@@ -162424,7 +162746,6 @@ async function createDeployment(accountId, workerName, versionTraffic, message)
162424
162746
  ([version_id, percentage]) => ({ version_id, percentage })
162425
162747
  ),
162426
162748
  annotations: {
162427
- "workers/triggered_by": "deployment",
162428
162749
  "workers/message": message
162429
162750
  }
162430
162751
  })
@@ -163276,6 +163597,9 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
163276
163597
  compatibility_flags: compatibilityFlags,
163277
163598
  usage_model: config.usage_model,
163278
163599
  keepVars: false,
163600
+ // the wrangler.toml should be the source-of-truth for vars
163601
+ keepSecrets: true,
163602
+ // until wrangler.toml specifies secret bindings, we need to inherit from the previous Worker Version
163279
163603
  logpush: void 0,
163280
163604
  placement,
163281
163605
  tail_consumers: config.tail_consumers,
@@ -163974,8 +164298,11 @@ var CommandLineArgsError = class extends UserError {
163974
164298
  };
163975
164299
  __name(CommandLineArgsError, "CommandLineArgsError");
163976
164300
  function createCLIParser(argv) {
163977
- const experimentalGradualRollouts = argv.includes(
163978
- "--experimental-gradual-rollouts"
164301
+ const experimentalGradualRollouts = (
164302
+ // original flag -- using internal product name (Gradual Rollouts) -- kept for temp back-compat
164303
+ argv.includes("--experimental-gradual-rollouts") || // new flag -- using external product name (Versions)
164304
+ argv.includes("--experimental-versions") || // new flag -- shorthand
164305
+ argv.includes("--x-versions")
163979
164306
  );
163980
164307
  const wrangler = yargs_default(argv).strict().showHelpOnFail(false).fail((msg, error2) => {
163981
164308
  if (!error2 || error2.name === "YError") {
@@ -164000,10 +164327,11 @@ function createCLIParser(argv) {
164000
164327
  alias: "j",
164001
164328
  describe: `Experimental: Support wrangler.json`,
164002
164329
  type: "boolean"
164003
- }).option("experimental-gradual-rollouts", {
164004
- describe: `Experimental: Support Gradual Rollouts`,
164330
+ }).option("experimental-versions", {
164331
+ describe: `Experimental: Support Worker Versions`,
164005
164332
  type: "boolean",
164006
- hidden: true
164333
+ hidden: true,
164334
+ alias: ["x-versions", "experimental-gradual-rollouts"]
164007
164335
  }).check((args) => {
164008
164336
  if (Object.keys(LOGGER_LEVELS).includes(args.logLevel)) {
164009
164337
  logger.loggerLevel = args.logLevel;
@@ -164370,10 +164698,15 @@ function createCLIParser(argv) {
164370
164698
  } else {
164371
164699
  logger.log(version);
164372
164700
  }
164701
+ logger.warn(
164702
+ "`wrangler version` is deprecated and will be removed in a future major version. Please use `wrangler --version` instead."
164703
+ );
164373
164704
  }
164374
164705
  );
164375
164706
  if (experimentalGradualRollouts) {
164376
- wrangler.command("versions", false, registerVersionsSubcommands);
164707
+ wrangler.command("versions", false, (yargs) => {
164708
+ return registerVersionsSubcommands(yargs.command(subHelp));
164709
+ });
164377
164710
  }
164378
164711
  wrangler.exitProcess(false);
164379
164712
  return wrangler;
@@ -165840,7 +166173,7 @@ Update them to point to this script instead?`;
165840
166173
  __name(publishCustomDomains, "publishCustomDomains");
165841
166174
  async function deploy(props) {
165842
166175
  const { config, accountId, name } = props;
165843
- if (accountId && name) {
166176
+ if (!props.dispatchNamespace && accountId && name) {
165844
166177
  try {
165845
166178
  const serviceMetaData = await fetchResult(
165846
166179
  `/accounts/${accountId}/workers/services/${name}`
@@ -165948,7 +166281,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
165948
166281
  const start = Date.now();
165949
166282
  const notProd = Boolean(!props.legacyEnv && props.env);
165950
166283
  const workerName = notProd ? `${scriptName} (${envName})` : scriptName;
165951
- const workerUrl = notProd ? `/accounts/${accountId}/workers/services/${scriptName}/environments/${envName}` : `/accounts/${accountId}/workers/scripts/${scriptName}`;
166284
+ 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
166285
  let available_on_subdomain = void 0;
165953
166286
  let deploymentId = null;
165954
166287
  const { format: format9 } = props.entry;
@@ -166122,6 +166455,8 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
166122
166455
  compatibility_flags: compatibilityFlags,
166123
166456
  usage_model: config.usage_model,
166124
166457
  keepVars,
166458
+ keepSecrets: keepVars,
166459
+ // keepVars implies keepSecrets
166125
166460
  logpush: props.logpush !== void 0 ? props.logpush : config.logpush,
166126
166461
  placement,
166127
166462
  tail_consumers: config.tail_consumers,
@@ -166219,6 +166554,11 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
166219
166554
  (0, import_node_assert17.default)(accountId, "Missing accountId");
166220
166555
  const uploadMs = Date.now() - start;
166221
166556
  const deployments2 = [];
166557
+ logger.log("Uploaded", workerName, formatTime3(uploadMs));
166558
+ if (props.dispatchNamespace !== void 0) {
166559
+ deployWfpUserWorker(props.dispatchNamespace, deploymentId);
166560
+ return;
166561
+ }
166222
166562
  if (deployToWorkersDev) {
166223
166563
  const userSubdomain = await getWorkersDevSubdomain(accountId);
166224
166564
  const scriptURL = props.legacyEnv || !props.env ? `${scriptName}.${userSubdomain}.workers.dev` : `${envName}.${scriptName}.${userSubdomain}.workers.dev`;
@@ -166287,7 +166627,6 @@ ${dashLink}`);
166287
166627
  }
166288
166628
  }
166289
166629
  }
166290
- logger.log("Uploaded", workerName, formatTime3(uploadMs));
166291
166630
  if (routesOnly.length > 0) {
166292
166631
  deployments2.push(
166293
166632
  publishRoutes(routesOnly, { workerUrl, scriptName, notProd }).then(() => {
@@ -166334,6 +166673,11 @@ ${dashLink}`);
166334
166673
  logger.log("Current Deployment ID:", deploymentId);
166335
166674
  }
166336
166675
  __name(deploy, "deploy");
166676
+ function deployWfpUserWorker(dispatchNamespace, deploymentId) {
166677
+ logger.log(" Dispatch Namespace:", dispatchNamespace);
166678
+ logger.log("Current Deployment ID:", deploymentId);
166679
+ }
166680
+ __name(deployWfpUserWorker, "deployWfpUserWorker");
166337
166681
  function helpIfErrorIsSizeOrScriptStartup2(err, dependencies) {
166338
166682
  if (errIsScriptSize2(err)) {
166339
166683
  printOffendingDependencies(dependencies);
@@ -167493,6 +167837,7 @@ async function createRemoteWorkerInit(props) {
167493
167837
  compatibility_flags: props.compatibilityFlags,
167494
167838
  usage_model: props.usageModel,
167495
167839
  keepVars: true,
167840
+ keepSecrets: true,
167496
167841
  logpush: false,
167497
167842
  placement: void 0,
167498
167843
  // no placement in dev
@@ -168839,6 +169184,9 @@ function devOptions(yargs) {
168839
169184
  describe: "Specify logging level",
168840
169185
  // Yargs requires this to type log-level properly
168841
169186
  default: "log"
169187
+ }).option("show-interactive-dev-session", {
169188
+ describe: "Show interactive dev session (defaults to true if the terminal supports interactivity)",
169189
+ type: "boolean"
168842
169190
  });
168843
169191
  }
168844
169192
  __name(devOptions, "devOptions");