wrangler 0.0.0-bd935cfd → 0.0.0-bdc121de

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": "0.0.0-bd935cfd",
3
+ "version": "0.0.0-bdc121de",
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.1"
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.18",
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 = "0.0.0-bd935cfd";
119655
+ var version = "0.0.0-bdc121de";
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,10 +129020,12 @@ 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,
128774
- limits
129027
+ limits,
129028
+ annotations
128775
129029
  } = worker;
128776
129030
  let { modules } = worker;
128777
129031
  const metadataBindings = [];
@@ -129015,6 +129269,15 @@ function createWorkerUploadForm(worker) {
129015
129269
  })
129016
129270
  );
129017
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
+ }
129018
129281
  const metadata = {
129019
129282
  ...main2.type !== "commonjs" ? { main_module: main2.name } : { body_part: main2.name },
129020
129283
  bindings: metadataBindings,
@@ -129023,11 +129286,12 @@ function createWorkerUploadForm(worker) {
129023
129286
  ...usage_model && { usage_model },
129024
129287
  ...migrations && { migrations },
129025
129288
  capnp_schema: capnpSchemaOutputFile,
129026
- ...keepVars && { keep_bindings: ["plain_text", "json"] },
129289
+ ...keep_bindings && { keep_bindings },
129027
129290
  ...logpush !== void 0 && { logpush },
129028
129291
  ...placement && { placement },
129029
129292
  ...tail_consumers && { tail_consumers },
129030
- ...limits && { limits }
129293
+ ...limits && { limits },
129294
+ ...annotations && { annotations }
129031
129295
  };
129032
129296
  if (bindings.unsafe?.metadata !== void 0) {
129033
129297
  for (const key of Object.keys(bindings.unsafe.metadata)) {
@@ -134522,8 +134786,10 @@ ${grayBar} ${msg}`);
134522
134786
  }
134523
134787
  clearLoop();
134524
134788
  } else {
134525
- logUpdate2(`
134789
+ if (msg) {
134790
+ logUpdate2(`
134526
134791
  ${grayBar} ${msg}`);
134792
+ }
134527
134793
  newline();
134528
134794
  }
134529
134795
  }
@@ -143784,6 +144050,9 @@ function deployOptions(yargs) {
143784
144050
  }).option("old-asset-ttl", {
143785
144051
  describe: "Expire old assets in given seconds rather than immediate deletion.",
143786
144052
  type: "number"
144053
+ }).option("dispatch-namespace", {
144054
+ describe: "Name of a dispatch namespace to deploy the Worker to (Workers for Platforms)",
144055
+ type: "string"
143787
144056
  });
143788
144057
  }
143789
144058
  __name(deployOptions, "deployOptions");
@@ -143868,7 +144137,8 @@ async function deployHandler(args) {
143868
144137
  keepVars: args.keepVars,
143869
144138
  logpush: args.logpush,
143870
144139
  oldAssetTtl: args.oldAssetTtl,
143871
- projectRoot
144140
+ projectRoot,
144141
+ dispatchNamespace: args.dispatchNamespace
143872
144142
  });
143873
144143
  }
143874
144144
  __name(deployHandler, "deployHandler");
@@ -145546,6 +145816,7 @@ function createWorkerBundleFormData(workerBundle) {
145546
145816
  compatibility_flags: void 0,
145547
145817
  usage_model: void 0,
145548
145818
  keepVars: void 0,
145819
+ keepSecrets: void 0,
145549
145820
  logpush: void 0,
145550
145821
  placement: void 0,
145551
145822
  tail_consumers: void 0,
@@ -147062,6 +147333,27 @@ We looked for the Functions directory (${(0, import_node_path39.basename)(
147062
147333
  };
147063
147334
  }, "validateArgs");
147064
147335
 
147336
+ // src/pages/build-env.ts
147337
+ init_import_meta_url();
147338
+ function Options8(yargs) {
147339
+ return yargs;
147340
+ }
147341
+ __name(Options8, "Options");
147342
+ var Handler8 = /* @__PURE__ */ __name(async (args) => {
147343
+ const config = readConfig(void 0, {
147344
+ ...args,
147345
+ // eslint-disable-next-line turbo/no-undeclared-env-vars
147346
+ env: process.env.PAGES_ENVIRONMENT
147347
+ });
147348
+ if (!config.pages_build_output_dir) {
147349
+ throw new FatalError("No Pages config file found");
147350
+ }
147351
+ const textVars = Object.fromEntries(
147352
+ Object.entries(config.vars).filter(([_3, v2]) => typeof v2 === "string")
147353
+ );
147354
+ logger.log(JSON.stringify(textVars));
147355
+ }, "Handler");
147356
+
147065
147357
  // src/pages/deploy.tsx
147066
147358
  init_import_meta_url();
147067
147359
  var import_node_child_process4 = require("node:child_process");
@@ -147568,15 +147860,15 @@ var import_node_path40 = require("node:path");
147568
147860
  var import_mime2 = __toESM(require_mime2());
147569
147861
  var import_minimatch = __toESM(require_minimatch());
147570
147862
  init_hash();
147571
- function Options8(yargs) {
147863
+ function Options9(yargs) {
147572
147864
  return yargs.positional("directory", {
147573
147865
  type: "string",
147574
147866
  demandOption: true,
147575
147867
  description: "The directory of static files to validate"
147576
147868
  });
147577
147869
  }
147578
- __name(Options8, "Options");
147579
- var Handler8 = /* @__PURE__ */ __name(async ({ directory }) => {
147870
+ __name(Options9, "Options");
147871
+ var Handler9 = /* @__PURE__ */ __name(async ({ directory }) => {
147580
147872
  if (!directory) {
147581
147873
  throw new FatalError("Must specify a directory.", 1);
147582
147874
  }
@@ -147649,7 +147941,7 @@ ${name} is ${prettyBytes(filestat.size, {
147649
147941
  }, "validate");
147650
147942
 
147651
147943
  // src/pages/upload.tsx
147652
- function Options9(yargs) {
147944
+ function Options10(yargs) {
147653
147945
  return yargs.positional("directory", {
147654
147946
  type: "string",
147655
147947
  demandOption: true,
@@ -147665,8 +147957,8 @@ function Options9(yargs) {
147665
147957
  }
147666
147958
  });
147667
147959
  }
147668
- __name(Options9, "Options");
147669
- var Handler9 = /* @__PURE__ */ __name(async ({
147960
+ __name(Options10, "Options");
147961
+ var Handler10 = /* @__PURE__ */ __name(async ({
147670
147962
  directory,
147671
147963
  outputManifestPath,
147672
147964
  skipCaching
@@ -148483,7 +148775,7 @@ async function promptSelectProject({
148483
148775
  __name(promptSelectProject, "promptSelectProject");
148484
148776
 
148485
148777
  // src/pages/deploy.tsx
148486
- function Options10(yargs) {
148778
+ function Options11(yargs) {
148487
148779
  return yargs.positional("directory", {
148488
148780
  type: "string",
148489
148781
  demandOption: true,
@@ -148530,8 +148822,8 @@ function Options10(yargs) {
148530
148822
  }
148531
148823
  });
148532
148824
  }
148533
- __name(Options10, "Options");
148534
- var Handler10 = /* @__PURE__ */ __name(async ({
148825
+ __name(Options11, "Options");
148826
+ var Handler11 = /* @__PURE__ */ __name(async ({
148535
148827
  _: _3,
148536
148828
  directory,
148537
148829
  projectName,
@@ -149020,7 +149312,7 @@ __name(createTail, "createTail");
149020
149312
  // src/pages/deployment-tails.ts
149021
149313
  var statusChoices = ["ok", "error", "canceled"];
149022
149314
  var isStatusChoiceList = /* @__PURE__ */ __name((data) => data?.every((d2) => statusChoices.includes(d2)) ?? false, "isStatusChoiceList");
149023
- function Options11(yargs) {
149315
+ function Options12(yargs) {
149024
149316
  return yargs.positional("deployment", {
149025
149317
  type: "string",
149026
149318
  description: "(Optional) ID or URL of the deployment to tail. Specify by environment if deployment ID is unknown."
@@ -149071,8 +149363,8 @@ function Options11(yargs) {
149071
149363
  array: true
149072
149364
  });
149073
149365
  }
149074
- __name(Options11, "Options");
149075
- async function Handler11({
149366
+ __name(Options12, "Options");
149367
+ async function Handler12({
149076
149368
  deployment,
149077
149369
  projectName,
149078
149370
  environment,
@@ -149216,7 +149508,7 @@ async function Handler11({
149216
149508
  logger.log(`Connected to deployment ${deploymentId}, waiting for logs...`);
149217
149509
  }
149218
149510
  }
149219
- __name(Handler11, "Handler");
149511
+ __name(Handler12, "Handler");
149220
149512
 
149221
149513
  // src/pages/deployments.tsx
149222
149514
  init_import_meta_url();
@@ -149313,7 +149605,8 @@ var BINDING_REGEXP = new RegExp(/^(?<binding>[^=]+)(?:=(?<ref>[^\s]+))?$/);
149313
149605
  var SERVICE_BINDING_REGEXP = new RegExp(
149314
149606
  /^(?<binding>[^=]+)=(?<service>[^@\s]+)(@(?<environment>.*)$)?$/
149315
149607
  );
149316
- function Options12(yargs) {
149608
+ var DEFAULT_SCRIPT_PATH = "_worker.js";
149609
+ function Options13(yargs) {
149317
149610
  return yargs.positional("directory", {
149318
149611
  type: "string",
149319
149612
  demandOption: void 0,
@@ -149321,7 +149614,8 @@ function Options12(yargs) {
149321
149614
  }).positional("command", {
149322
149615
  type: "string",
149323
149616
  demandOption: void 0,
149324
- description: "The proxy command to run"
149617
+ description: "The proxy command to run [deprecated]"
149618
+ // no official way to deprecate a positional argument
149325
149619
  }).options({
149326
149620
  local: {
149327
149621
  type: "boolean",
@@ -149363,12 +149657,14 @@ function Options12(yargs) {
149363
149657
  },
149364
149658
  proxy: {
149365
149659
  type: "number",
149366
- description: "The port to proxy (where the static assets are served)"
149660
+ description: "The port to proxy (where the static assets are served)",
149661
+ deprecated: true
149367
149662
  },
149368
149663
  "script-path": {
149369
149664
  type: "string",
149370
- default: "_worker.js",
149371
- description: "The location of the single Worker script if not using functions"
149665
+ description: "The location of the single Worker script if not using functions [default: _worker.js]",
149666
+ // hacking in a fake default message here so we can detect when user is setting this and show a deprecation message
149667
+ deprecated: true
149372
149668
  },
149373
149669
  bundle: {
149374
149670
  type: "boolean",
@@ -149456,11 +149752,15 @@ function Options12(yargs) {
149456
149752
  "log-level": {
149457
149753
  choices: ["debug", "info", "log", "warn", "error", "none"],
149458
149754
  describe: "Specify logging level"
149755
+ },
149756
+ "show-interactive-dev-session": {
149757
+ describe: "Show interactive dev session (defaults to true if the terminal supports interactivity)",
149758
+ type: "boolean"
149459
149759
  }
149460
149760
  });
149461
149761
  }
149462
- __name(Options12, "Options");
149463
- var Handler12 = /* @__PURE__ */ __name(async ({
149762
+ __name(Options13, "Options");
149763
+ var Handler13 = /* @__PURE__ */ __name(async ({
149464
149764
  directory,
149465
149765
  compatibilityDate,
149466
149766
  compatibilityFlags,
@@ -149487,7 +149787,8 @@ var Handler12 = /* @__PURE__ */ __name(async ({
149487
149787
  experimentalLocal,
149488
149788
  config,
149489
149789
  _: [_pages, _dev, ...remaining],
149490
- logLevel
149790
+ logLevel,
149791
+ showInteractiveDevSession
149491
149792
  }) => {
149492
149793
  if (logLevel) {
149493
149794
  logger.loggerLevel = logLevel;
@@ -149500,6 +149801,13 @@ var Handler12 = /* @__PURE__ */ __name(async ({
149500
149801
  if (config) {
149501
149802
  throw new FatalError("Pages does not support wrangler.toml", 1);
149502
149803
  }
149804
+ if (singleWorkerScriptPath !== void 0) {
149805
+ logger.warn(
149806
+ `\`--script-path\` is deprecated and will be removed in a future version of Wrangler.
149807
+ The Worker script should be named \`_worker.js\` and located in the build output directory of your project (specified with \`wrangler pages dev <directory>\`).`
149808
+ );
149809
+ }
149810
+ singleWorkerScriptPath ??= DEFAULT_SCRIPT_PATH;
149503
149811
  const command2 = remaining;
149504
149812
  let proxyPort;
149505
149813
  if (directory !== void 0 && command2.length > 0) {
@@ -149508,6 +149816,11 @@ var Handler12 = /* @__PURE__ */ __name(async ({
149508
149816
  1
149509
149817
  );
149510
149818
  } else if (directory === void 0) {
149819
+ logger.warn(
149820
+ `Specifying a \`-- <command>\` or \`--proxy\` is deprecated and will be removed in a future version of Wrangler.
149821
+ Build your application to a directory and run the \`wrangler pages dev <directory>\` instead.
149822
+ This results in a more faithful emulation of production behavior.`
149823
+ );
149511
149824
  proxyPort = await spawnProxyProcess({
149512
149825
  port: requestedProxyPort,
149513
149826
  command: command2
@@ -149879,7 +150192,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates/ for
149879
150192
  },
149880
150193
  liveReload,
149881
150194
  forceLocal: true,
149882
- showInteractiveDevSession: void 0,
150195
+ showInteractiveDevSession,
149883
150196
  testMode: false,
149884
150197
  watch: true
149885
150198
  }
@@ -150074,8 +150387,8 @@ function pages(yargs) {
150074
150387
  return yargs.command(
150075
150388
  "dev [directory] [-- command..]",
150076
150389
  "\u{1F9D1}\u200D\u{1F4BB} Develop your full-stack Pages application locally",
150077
- Options12,
150078
- Handler12
150390
+ Options13,
150391
+ Handler13
150079
150392
  ).command(
150080
150393
  "functions",
150081
150394
  false,
@@ -150084,6 +150397,11 @@ function pages(yargs) {
150084
150397
  "Compile a folder of Cloudflare Pages Functions into a single Worker",
150085
150398
  Options7,
150086
150399
  Handler7
150400
+ ).command(
150401
+ "build-env",
150402
+ "Render a list of environment variables from the config file",
150403
+ Options8,
150404
+ Handler8
150087
150405
  ).command(
150088
150406
  "optimize-routes [routesPath] [outputRoutesPath]",
150089
150407
  "Consolidate and optimize the route paths declared in _routes.json",
@@ -150108,11 +150426,11 @@ function pages(yargs) {
150108
150426
  "Delete a Cloudflare Pages project",
150109
150427
  DeleteOptions,
150110
150428
  DeleteHandler
150111
- ).command("upload [directory]", false, Options9, Handler9).command(
150429
+ ).command("upload [directory]", false, Options10, Handler10).command(
150112
150430
  "validate [directory]",
150113
150431
  false,
150114
- Options8,
150115
- Handler8
150432
+ Options9,
150433
+ Handler9
150116
150434
  )
150117
150435
  ).command(
150118
150436
  "deployment",
@@ -150125,19 +150443,19 @@ function pages(yargs) {
150125
150443
  ).command(
150126
150444
  "create [directory]",
150127
150445
  "\u{1F199} Publish a directory of static assets as a Pages deployment",
150128
- Options10,
150129
- Handler10
150446
+ Options11,
150447
+ Handler11
150130
150448
  ).command(
150131
150449
  "tail [deployment]",
150132
150450
  "Start a tailing session for a project's deployment and livestream logs from your Functions",
150133
- Options11,
150134
- Handler11
150451
+ Options12,
150452
+ Handler12
150135
150453
  )
150136
150454
  ).command(
150137
150455
  ["deploy [directory]", "publish [directory]"],
150138
150456
  "\u{1F199} Deploy a directory of static assets as a Pages deployment",
150139
- Options10,
150140
- Handler10
150457
+ Options11,
150458
+ Handler11
150141
150459
  );
150142
150460
  }
150143
150461
  __name(pages, "pages");
@@ -151239,6 +151557,53 @@ async function putR2Sippy(accountId, bucketName, params, jurisdiction) {
151239
151557
  );
151240
151558
  }
151241
151559
  __name(putR2Sippy, "putR2Sippy");
151560
+ var actionsForEventCategories = {
151561
+ object_create: ["PutObject", "CompleteMultipartUpload", "CopyObject"],
151562
+ object_delete: ["DeleteObject", "LifecycleDeletion"]
151563
+ };
151564
+ function eventNotificationHeaders(apiCredentials) {
151565
+ const headers = {
151566
+ "Content-Type": "application/json"
151567
+ };
151568
+ if ("apiToken" in apiCredentials) {
151569
+ headers["Authorization"] = `Bearer ${apiCredentials.apiToken}`;
151570
+ } else {
151571
+ headers["X-Auth-Key"] = apiCredentials.authKey;
151572
+ headers["X-Auth-Email"] = apiCredentials.authEmail;
151573
+ }
151574
+ return headers;
151575
+ }
151576
+ __name(eventNotificationHeaders, "eventNotificationHeaders");
151577
+ async function putEventNotificationConfig(apiCredentials, accountId, bucketName, queueUUID, eventTypes, prefix, suffix) {
151578
+ const headers = eventNotificationHeaders(apiCredentials);
151579
+ let actions = [];
151580
+ for (const et of eventTypes) {
151581
+ actions = actions.concat(actionsForEventCategories[et]);
151582
+ }
151583
+ const body = {
151584
+ rules: [{ prefix, suffix, actions }]
151585
+ };
151586
+ logger.log(
151587
+ `Sending this configuration to "${bucketName}":
151588
+ ${JSON.stringify(body)}`
151589
+ );
151590
+ return await fetchResult(
151591
+ `/accounts/${accountId}/event_notifications/r2/${bucketName}/configuration/queues/${queueUUID}`,
151592
+ { method: "PUT", body: JSON.stringify(body), headers }
151593
+ );
151594
+ }
151595
+ __name(putEventNotificationConfig, "putEventNotificationConfig");
151596
+ async function deleteEventNotificationConfig(apiCredentials, accountId, bucketName, queueUUID) {
151597
+ const headers = eventNotificationHeaders(apiCredentials);
151598
+ logger.log(
151599
+ `Disabling event notifications for "${bucketName}" to queue ${queueUUID}...`
151600
+ );
151601
+ return await fetchResult(
151602
+ `/accounts/${accountId}/event_notifications/r2/${bucketName}/configuration/queues/${queueUUID}`,
151603
+ { method: "DELETE", headers }
151604
+ );
151605
+ }
151606
+ __name(deleteEventNotificationConfig, "deleteEventNotificationConfig");
151242
151607
 
151243
151608
  // src/r2/sippy.ts
151244
151609
  init_import_meta_url();
@@ -151918,6 +152283,94 @@ ${key} is ${prettyBytes(objectSize, {
151918
152283
  );
151919
152284
  }
151920
152285
  );
152286
+ r2BucketYargs.command(
152287
+ "event-notification",
152288
+ "Manage event notifications for an R2 bucket",
152289
+ (r2EvNotifyYargs) => {
152290
+ return r2EvNotifyYargs.command(
152291
+ "create <bucket>",
152292
+ "Create new event notification configuration for an R2 bucket",
152293
+ (yargs) => {
152294
+ return yargs.positional("bucket", {
152295
+ describe: "The name of the bucket for which notifications will be emitted",
152296
+ type: "string",
152297
+ demandOption: true
152298
+ }).option("event-types", {
152299
+ describe: "Specify the kinds of object events to emit notifications for. ex. '--event-types object_create object_delete'",
152300
+ alias: "event-type",
152301
+ choices: Object.keys(actionsForEventCategories),
152302
+ demandOption: true,
152303
+ requiresArg: true,
152304
+ type: "array"
152305
+ }).option("prefix", {
152306
+ describe: "only actions on objects with this prefix will emit notifications",
152307
+ requiresArg: false,
152308
+ type: "string"
152309
+ }).option("suffix", {
152310
+ describe: "only actions on objects with this suffix will emit notifications",
152311
+ type: "string"
152312
+ }).option("queue", {
152313
+ describe: "The ID of the queue to which event notifications will be sent. ex '--queue deadbeef-0123-4567-8910-abcdefgabcde'",
152314
+ demandOption: true,
152315
+ requiresArg: true,
152316
+ type: "string"
152317
+ });
152318
+ },
152319
+ async (args) => {
152320
+ await printWranglerBanner();
152321
+ const config = readConfig(args.config, args);
152322
+ const accountId = await requireAuth(config);
152323
+ const apiCreds = requireApiToken();
152324
+ const {
152325
+ bucket,
152326
+ queue,
152327
+ eventTypes,
152328
+ prefix = "",
152329
+ suffix = ""
152330
+ } = args;
152331
+ await putEventNotificationConfig(
152332
+ apiCreds,
152333
+ accountId,
152334
+ `${bucket}`,
152335
+ `${queue}`,
152336
+ eventTypes,
152337
+ `${prefix}`,
152338
+ `${suffix}`
152339
+ );
152340
+ logger.log("Configuration created successfully!");
152341
+ }
152342
+ ).command(
152343
+ "delete <bucket>",
152344
+ "Delete event notification configuration for an R2 bucket and queue",
152345
+ (yargs) => {
152346
+ return yargs.positional("bucket", {
152347
+ describe: "The name of the bucket for which notifications will be emitted",
152348
+ type: "string",
152349
+ demandOption: true
152350
+ }).option("queue", {
152351
+ describe: "The ID of the queue that is configured to receive notifications. ex '--queue deadbeef-0123-4567-8910-abcdefgabcde'",
152352
+ demandOption: true,
152353
+ requiresArg: true,
152354
+ type: "string"
152355
+ });
152356
+ },
152357
+ async (args) => {
152358
+ await printWranglerBanner();
152359
+ const config = readConfig(args.config, args);
152360
+ const accountId = await requireAuth(config);
152361
+ const apiCreds = requireApiToken();
152362
+ const { bucket, queue } = args;
152363
+ await deleteEventNotificationConfig(
152364
+ apiCreds,
152365
+ accountId,
152366
+ `${bucket}`,
152367
+ `${queue}`
152368
+ );
152369
+ logger.log("Configuration deleted successfully!");
152370
+ }
152371
+ );
152372
+ }
152373
+ );
151921
152374
  return r2BucketYargs;
151922
152375
  });
151923
152376
  }
@@ -151984,6 +152437,8 @@ async function createDraftWorker({
151984
152437
  usage_model: void 0,
151985
152438
  keepVars: false,
151986
152439
  // this doesn't matter since it's a new script anyway
152440
+ keepSecrets: false,
152441
+ // this doesn't matter since it's a new script anyway
151987
152442
  logpush: false,
151988
152443
  placement: void 0,
151989
152444
  tail_consumers: void 0,
@@ -161632,13 +162087,6 @@ async function tailHandler(args) {
161632
162087
  `Successfully created tail, expires at ${expiration.toLocaleString()}`
161633
162088
  );
161634
162089
  }
161635
- (0, import_signal_exit7.default)(async () => {
161636
- tail.terminate();
161637
- await deleteTail();
161638
- await sendMetricsEvent("end log stream", {
161639
- sendMetrics: config.send_metrics
161640
- });
161641
- });
161642
162090
  const printLog = args.format === "pretty" ? prettyPrintLogs : jsonPrintLogs;
161643
162091
  tail.on("message", printLog);
161644
162092
  while (tail.readyState !== tail.OPEN) {
@@ -161661,13 +162109,42 @@ async function tailHandler(args) {
161661
162109
  if (args.format === "pretty") {
161662
162110
  logger.log(`Connected to ${scriptDisplayName}, waiting for logs...`);
161663
162111
  }
161664
- tail.on("close", async () => {
162112
+ const cancelPing = startWebSocketPing();
162113
+ tail.on("close", exit6);
162114
+ (0, import_signal_exit7.default)(exit6);
162115
+ async function exit6() {
162116
+ cancelPing();
161665
162117
  tail.terminate();
161666
162118
  await deleteTail();
161667
162119
  await sendMetricsEvent("end log stream", {
161668
162120
  sendMetrics: config.send_metrics
161669
162121
  });
161670
- });
162122
+ }
162123
+ __name(exit6, "exit");
162124
+ function startWebSocketPing() {
162125
+ const PING_MESSAGE = Buffer.from("wrangler tail ping");
162126
+ const PING_INTERVAL = 1e4;
162127
+ let waitingForPong = false;
162128
+ const pingInterval = setInterval(() => {
162129
+ if (waitingForPong) {
162130
+ console.log(args.format);
162131
+ throw createFatalError(
162132
+ "Tail disconnected, exiting.",
162133
+ args.format === "json",
162134
+ 1
162135
+ );
162136
+ }
162137
+ waitingForPong = true;
162138
+ tail.ping(PING_MESSAGE);
162139
+ }, PING_INTERVAL);
162140
+ tail.on("pong", (data) => {
162141
+ if (data.equals(PING_MESSAGE)) {
162142
+ waitingForPong = false;
162143
+ }
162144
+ });
162145
+ return () => clearInterval(pingInterval);
162146
+ }
162147
+ __name(startWebSocketPing, "startWebSocketPing");
161671
162148
  }
161672
162149
  __name(tailHandler, "tailHandler");
161673
162150
 
@@ -162422,7 +162899,6 @@ async function createDeployment(accountId, workerName, versionTraffic, message)
162422
162899
  ([version_id, percentage]) => ({ version_id, percentage })
162423
162900
  ),
162424
162901
  annotations: {
162425
- "workers/triggered_by": "deployment",
162426
162902
  "workers/message": message
162427
162903
  }
162428
162904
  })
@@ -162910,6 +163386,7 @@ async function versionsListHandler(args) {
162910
163386
  Message: version3.annotations?.["workers/message"] || BLANK_INPUT2
162911
163387
  });
162912
163388
  logRaw(formattedVersion);
163389
+ logRaw(``);
162913
163390
  }
162914
163391
  }
162915
163392
  __name(versionsListHandler, "versionsListHandler");
@@ -163061,7 +163538,7 @@ async function versionsUpload(props) {
163061
163538
  const { default_environment } = serviceMetaData;
163062
163539
  if (default_environment.script.last_deployed_from === "dash") {
163063
163540
  logger.warn(
163064
- `You are about to publish a Workers Service that was last published via the Cloudflare Dashboard.
163541
+ `You are about to upload a Worker Version that was last published via the Cloudflare Dashboard.
163065
163542
  Edits that have been made via the dashboard will be overridden by your local code and config.`
163066
163543
  );
163067
163544
  if (!await confirm("Would you like to continue?")) {
@@ -163069,8 +163546,8 @@ Edits that have been made via the dashboard will be overridden by your local cod
163069
163546
  }
163070
163547
  } else if (default_environment.script.last_deployed_from === "api") {
163071
163548
  logger.warn(
163072
- `You are about to publish a Workers Service that was last updated via the script API.
163073
- Edits that have been made via the script API will be overridden by your local code and config.`
163549
+ `You are about to upload a Workers Version that was last updated via the API.
163550
+ Edits that have been made via the API will be overridden by your local code and config.`
163074
163551
  );
163075
163552
  if (!await confirm("Would you like to continue?")) {
163076
163553
  return;
@@ -163084,7 +163561,7 @@ Edits that have been made via the script API will be overridden by your local co
163084
163561
  }
163085
163562
  if (!(props.compatibilityDate || config.compatibility_date)) {
163086
163563
  const compatibilityDateStr = `${(/* @__PURE__ */ new Date()).getFullYear()}-${((/* @__PURE__ */ new Date()).getMonth() + 1 + "").padStart(2, "0")}-${((/* @__PURE__ */ new Date()).getDate() + "").padStart(2, "0")}`;
163087
- throw new UserError(`A compatibility_date is required when publishing. Add the following to your wrangler.toml file:.
163564
+ throw new UserError(`A compatibility_date is required when uploading a Worker Version. Add the following to your wrangler.toml file:.
163088
163565
  \`\`\`
163089
163566
  compatibility_date = "${compatibilityDateStr}"
163090
163567
  \`\`\`
@@ -163093,7 +163570,6 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
163093
163570
  }
163094
163571
  const jsxFactory = props.jsxFactory || config.jsx_factory;
163095
163572
  const jsxFragment = props.jsxFragment || config.jsx_fragment;
163096
- const keepVars = props.keepVars || config.keep_vars;
163097
163573
  const minify = props.minify ?? config.minify;
163098
163574
  const legacyNodeCompat = props.nodeCompat ?? config.node_compat;
163099
163575
  if (legacyNodeCompat) {
@@ -163121,7 +163597,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
163121
163597
  const scriptName = props.name;
163122
163598
  if (!scriptName) {
163123
163599
  throw new UserError(
163124
- 'You need to provide a name when publishing a worker. Either pass it as a cli arg with `--name <name>` or in your config file as `name = "<name>"`'
163600
+ 'You need to provide a name when uploading a Worker Version. Either pass it as a cli arg with `--name <name>` or in your config file as `name = "<name>"`'
163125
163601
  );
163126
163602
  }
163127
163603
  if (config.site && !config.site.bucket) {
@@ -163273,11 +163749,18 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
163273
163749
  compatibility_date: props.compatibilityDate ?? config.compatibility_date,
163274
163750
  compatibility_flags: compatibilityFlags,
163275
163751
  usage_model: config.usage_model,
163276
- keepVars,
163752
+ keepVars: false,
163753
+ // the wrangler.toml should be the source-of-truth for vars
163754
+ keepSecrets: true,
163755
+ // until wrangler.toml specifies secret bindings, we need to inherit from the previous Worker Version
163277
163756
  logpush: void 0,
163278
163757
  placement,
163279
163758
  tail_consumers: config.tail_consumers,
163280
- limits: config.limits
163759
+ limits: config.limits,
163760
+ annotations: {
163761
+ "workers/message": props.message,
163762
+ "workers/tag": props.tag
163763
+ }
163281
163764
  };
163282
163765
  const bundleSizePromise = printBundleSize(
163283
163766
  { name: import_node_path46.default.basename(resolvedEntryPointPath), content },
@@ -163303,14 +163786,6 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
163303
163786
  await ensureQueuesExist(config);
163304
163787
  try {
163305
163788
  const body = createWorkerUploadForm(worker);
163306
- body.set(
163307
- "annotations",
163308
- JSON.stringify({
163309
- "workers/message": props.message,
163310
- "workers/tag": props.tag,
163311
- "workers/triggered_by": "wrangler"
163312
- })
163313
- );
163314
163789
  const result = await fetchResult(
163315
163790
  workerUrl,
163316
163791
  {
@@ -163558,10 +164033,6 @@ function versionsUploadOptions(yargs) {
163558
164033
  }).option("dry-run", {
163559
164034
  describe: "Don't actually deploy",
163560
164035
  type: "boolean"
163561
- }).option("keep-vars", {
163562
- describe: "Stop wrangler from deleting vars that are not present in the wrangler.toml\nBy default Wrangler will remove all vars and replace them with those found in the wrangler.toml configuration.\nIf your development approach is to modify vars after deployment via the dashboard you may wish to set this flag.",
163563
- default: false,
163564
- type: "boolean"
163565
164036
  }).option("tag", {
163566
164037
  describe: "A tag for this Worker Gradual Rollouts Version",
163567
164038
  type: "string",
@@ -163618,7 +164089,7 @@ async function versionsUploadHandler(args) {
163618
164089
  outDir: args.outdir,
163619
164090
  dryRun: args.dryRun,
163620
164091
  noBundle: !(args.bundle ?? !config.no_bundle),
163621
- keepVars: args.keepVars,
164092
+ keepVars: false,
163622
164093
  projectRoot,
163623
164094
  tag: args.tag,
163624
164095
  message: args.message
@@ -163980,8 +164451,11 @@ var CommandLineArgsError = class extends UserError {
163980
164451
  };
163981
164452
  __name(CommandLineArgsError, "CommandLineArgsError");
163982
164453
  function createCLIParser(argv) {
163983
- const experimentalGradualRollouts = argv.includes(
163984
- "--experimental-gradual-rollouts"
164454
+ const experimentalGradualRollouts = (
164455
+ // original flag -- using internal product name (Gradual Rollouts) -- kept for temp back-compat
164456
+ argv.includes("--experimental-gradual-rollouts") || // new flag -- using external product name (Versions)
164457
+ argv.includes("--experimental-versions") || // new flag -- shorthand
164458
+ argv.includes("--x-versions")
163985
164459
  );
163986
164460
  const wrangler = yargs_default(argv).strict().showHelpOnFail(false).fail((msg, error2) => {
163987
164461
  if (!error2 || error2.name === "YError") {
@@ -164006,10 +164480,11 @@ function createCLIParser(argv) {
164006
164480
  alias: "j",
164007
164481
  describe: `Experimental: Support wrangler.json`,
164008
164482
  type: "boolean"
164009
- }).option("experimental-gradual-rollouts", {
164010
- describe: `Experimental: Support Gradual Rollouts`,
164483
+ }).option("experimental-versions", {
164484
+ describe: `Experimental: Support Worker Versions`,
164011
164485
  type: "boolean",
164012
- hidden: true
164486
+ hidden: true,
164487
+ alias: ["x-versions", "experimental-gradual-rollouts"]
164013
164488
  }).check((args) => {
164014
164489
  if (Object.keys(LOGGER_LEVELS).includes(args.logLevel)) {
164015
164490
  logger.loggerLevel = args.logLevel;
@@ -164376,10 +164851,15 @@ function createCLIParser(argv) {
164376
164851
  } else {
164377
164852
  logger.log(version);
164378
164853
  }
164854
+ logger.warn(
164855
+ "`wrangler version` is deprecated and will be removed in a future major version. Please use `wrangler --version` instead."
164856
+ );
164379
164857
  }
164380
164858
  );
164381
164859
  if (experimentalGradualRollouts) {
164382
- wrangler.command("versions", false, registerVersionsSubcommands);
164860
+ wrangler.command("versions", false, (yargs) => {
164861
+ return registerVersionsSubcommands(yargs.command(subHelp));
164862
+ });
164383
164863
  }
164384
164864
  wrangler.exitProcess(false);
164385
164865
  return wrangler;
@@ -165846,7 +166326,7 @@ Update them to point to this script instead?`;
165846
166326
  __name(publishCustomDomains, "publishCustomDomains");
165847
166327
  async function deploy(props) {
165848
166328
  const { config, accountId, name } = props;
165849
- if (accountId && name) {
166329
+ if (!props.dispatchNamespace && accountId && name) {
165850
166330
  try {
165851
166331
  const serviceMetaData = await fetchResult(
165852
166332
  `/accounts/${accountId}/workers/services/${name}`
@@ -165954,7 +166434,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
165954
166434
  const start = Date.now();
165955
166435
  const notProd = Boolean(!props.legacyEnv && props.env);
165956
166436
  const workerName = notProd ? `${scriptName} (${envName})` : scriptName;
165957
- const workerUrl = notProd ? `/accounts/${accountId}/workers/services/${scriptName}/environments/${envName}` : `/accounts/${accountId}/workers/scripts/${scriptName}`;
166437
+ 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}`;
165958
166438
  let available_on_subdomain = void 0;
165959
166439
  let deploymentId = null;
165960
166440
  const { format: format9 } = props.entry;
@@ -166128,6 +166608,8 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
166128
166608
  compatibility_flags: compatibilityFlags,
166129
166609
  usage_model: config.usage_model,
166130
166610
  keepVars,
166611
+ keepSecrets: keepVars,
166612
+ // keepVars implies keepSecrets
166131
166613
  logpush: props.logpush !== void 0 ? props.logpush : config.logpush,
166132
166614
  placement,
166133
166615
  tail_consumers: config.tail_consumers,
@@ -166225,6 +166707,11 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
166225
166707
  (0, import_node_assert17.default)(accountId, "Missing accountId");
166226
166708
  const uploadMs = Date.now() - start;
166227
166709
  const deployments2 = [];
166710
+ logger.log("Uploaded", workerName, formatTime3(uploadMs));
166711
+ if (props.dispatchNamespace !== void 0) {
166712
+ deployWfpUserWorker(props.dispatchNamespace, deploymentId);
166713
+ return;
166714
+ }
166228
166715
  if (deployToWorkersDev) {
166229
166716
  const userSubdomain = await getWorkersDevSubdomain(accountId);
166230
166717
  const scriptURL = props.legacyEnv || !props.env ? `${scriptName}.${userSubdomain}.workers.dev` : `${envName}.${scriptName}.${userSubdomain}.workers.dev`;
@@ -166293,7 +166780,6 @@ ${dashLink}`);
166293
166780
  }
166294
166781
  }
166295
166782
  }
166296
- logger.log("Uploaded", workerName, formatTime3(uploadMs));
166297
166783
  if (routesOnly.length > 0) {
166298
166784
  deployments2.push(
166299
166785
  publishRoutes(routesOnly, { workerUrl, scriptName, notProd }).then(() => {
@@ -166340,6 +166826,11 @@ ${dashLink}`);
166340
166826
  logger.log("Current Deployment ID:", deploymentId);
166341
166827
  }
166342
166828
  __name(deploy, "deploy");
166829
+ function deployWfpUserWorker(dispatchNamespace, deploymentId) {
166830
+ logger.log(" Dispatch Namespace:", dispatchNamespace);
166831
+ logger.log("Current Deployment ID:", deploymentId);
166832
+ }
166833
+ __name(deployWfpUserWorker, "deployWfpUserWorker");
166343
166834
  function helpIfErrorIsSizeOrScriptStartup2(err, dependencies) {
166344
166835
  if (errIsScriptSize2(err)) {
166345
166836
  printOffendingDependencies(dependencies);
@@ -167499,6 +167990,7 @@ async function createRemoteWorkerInit(props) {
167499
167990
  compatibility_flags: props.compatibilityFlags,
167500
167991
  usage_model: props.usageModel,
167501
167992
  keepVars: true,
167993
+ keepSecrets: true,
167502
167994
  logpush: false,
167503
167995
  placement: void 0,
167504
167996
  // no placement in dev
@@ -168845,6 +169337,9 @@ function devOptions(yargs) {
168845
169337
  describe: "Specify logging level",
168846
169338
  // Yargs requires this to type log-level properly
168847
169339
  default: "log"
169340
+ }).option("show-interactive-dev-session", {
169341
+ describe: "Show interactive dev session (defaults to true if the terminal supports interactivity)",
169342
+ type: "boolean"
168848
169343
  });
168849
169344
  }
168850
169345
  __name(devOptions, "devOptions");