wrangler 3.114.9 → 3.114.11

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/wrangler-dist/cli.js +114 -70
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "3.114.9",
3
+ "version": "3.114.11",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -137,10 +137,10 @@
137
137
  "xdg-app-paths": "^8.3.0",
138
138
  "xxhash-wasm": "^1.0.1",
139
139
  "yargs": "^17.7.2",
140
- "@cloudflare/eslint-config-worker": "1.1.0",
141
- "@cloudflare/workers-shared": "0.15.1",
142
140
  "@cloudflare/cli": "1.1.1",
141
+ "@cloudflare/eslint-config-worker": "1.1.0",
143
142
  "@cloudflare/pages-shared": "0.13.18",
143
+ "@cloudflare/workers-shared": "0.15.1",
144
144
  "@cloudflare/workers-tsconfig": "0.0.0"
145
145
  },
146
146
  "peerDependencies": {
@@ -81450,7 +81450,7 @@ var import_undici3 = __toESM(require_undici());
81450
81450
 
81451
81451
  // package.json
81452
81452
  var name = "wrangler";
81453
- var version = "3.114.9";
81453
+ var version = "3.114.11";
81454
81454
 
81455
81455
  // src/environment-variables/misc-variables.ts
81456
81456
  init_import_meta_url();
@@ -81561,9 +81561,6 @@ var getBuildConditionsFromEnv = getEnvironmentVariableFactory({
81561
81561
  var getBuildPlatformFromEnv = getEnvironmentVariableFactory({
81562
81562
  variableName: "WRANGLER_BUILD_PLATFORM"
81563
81563
  });
81564
- var getUnenvResolvePathsFromEnv = getEnvironmentVariableFactory({
81565
- variableName: "WRANGLER_UNENV_RESOLVE_PATHS"
81566
- });
81567
81564
  var getRegistryPath = getEnvironmentVariableFactory({
81568
81565
  variableName: "WRANGLER_REGISTRY_PATH",
81569
81566
  defaultValue() {
@@ -101188,6 +101185,7 @@ var import_miniflare14 = require("miniflare");
101188
101185
  var import_undici4 = __toESM(require_undici());
101189
101186
  var API_MAX = 1e4;
101190
101187
  var BATCH_KEY_MAX = API_MAX / 10;
101188
+ var BATCH_MAX_ERRORS_WARNINGS = 12;
101191
101189
  async function createKVNamespace(accountId, title) {
101192
101190
  const response = await fetchResult(
101193
101191
  `/accounts/${accountId}/storage/kv/namespaces`,
@@ -103719,16 +103717,16 @@ var import_node_module2 = require("node:module");
103719
103717
  var import_node_path26 = __toESM(require("node:path"));
103720
103718
  var REQUIRED_NODE_BUILT_IN_NAMESPACE = "node-built-in-modules";
103721
103719
  var REQUIRED_UNENV_ALIAS_NAMESPACE = "required-unenv-alias";
103722
- async function nodejsHybridPlugin(_unenvResolvePaths) {
103723
- const { defineEnv } = await import("unenv");
103724
- const { cloudflare } = await import("@cloudflare/unenv-preset");
103725
- const { alias, inject, external, polyfill: polyfill2 } = defineEnv({
103726
- presets: [cloudflare],
103727
- npmShims: true
103728
- }).env;
103720
+ function nodejsHybridPlugin() {
103729
103721
  return {
103730
103722
  name: "hybrid-nodejs_compat",
103731
- setup(build5) {
103723
+ async setup(build5) {
103724
+ const { defineEnv } = await import("unenv");
103725
+ const { cloudflare } = await import("@cloudflare/unenv-preset");
103726
+ const { alias, inject, external, polyfill: polyfill2 } = defineEnv({
103727
+ presets: [cloudflare],
103728
+ npmShims: true
103729
+ }).env;
103732
103730
  errorOnServiceWorkerFormat(build5);
103733
103731
  handleRequireCallsToNodeJSBuiltins(build5);
103734
103732
  handleUnenvAliasedPackages(build5, alias, external);
@@ -103990,9 +103988,8 @@ var standardURLPlugin = /* @__PURE__ */ __name(() => ({
103990
103988
  }), "standardURLPlugin");
103991
103989
 
103992
103990
  // src/deployment-bundle/esbuild-plugins/nodejs-plugins.ts
103993
- async function getNodeJSCompatPlugins({
103994
- mode,
103995
- unenvResolvePaths
103991
+ function getNodeJSCompatPlugins({
103992
+ mode
103996
103993
  }) {
103997
103994
  switch (mode) {
103998
103995
  case "als":
@@ -104007,7 +104004,7 @@ async function getNodeJSCompatPlugins({
104007
104004
  case "v1":
104008
104005
  return [nodejsCompatPlugin(mode)];
104009
104006
  case "v2":
104010
- return [await nodejsHybridPlugin(unenvResolvePaths)];
104007
+ return [nodejsHybridPlugin()];
104011
104008
  case null:
104012
104009
  return [nodejsCompatPlugin(mode)];
104013
104010
  }
@@ -104216,7 +104213,6 @@ async function bundleWorker(entry, destination, {
104216
104213
  });
104217
104214
  }
104218
104215
  };
104219
- const unenvResolvePaths = getUnenvResolvePathsFromEnv()?.split(",");
104220
104216
  const buildOptions2 = {
104221
104217
  // Don't use entryFile here as the file may have been changed when applying the middleware
104222
104218
  entryPoints: [entry.file],
@@ -104256,9 +104252,8 @@ async function bundleWorker(entry, destination, {
104256
104252
  plugins: [
104257
104253
  aliasPlugin,
104258
104254
  moduleCollector.plugin,
104259
- ...await getNodeJSCompatPlugins({
104260
- mode: nodejsCompatMode ?? null,
104261
- unenvResolvePaths
104255
+ ...getNodeJSCompatPlugins({
104256
+ mode: nodejsCompatMode ?? null
104262
104257
  }),
104263
104258
  cloudflareInternalPlugin,
104264
104259
  buildResultPlugin,
@@ -104952,6 +104947,23 @@ function logBuildOutput(nodejsCompatMode, onStart, updateBundle) {
104952
104947
  }
104953
104948
  __name(logBuildOutput, "logBuildOutput");
104954
104949
 
104950
+ // src/deployment-bundle/no-bundle-worker.ts
104951
+ init_import_meta_url();
104952
+ async function noBundleWorker(entry, rules, outDir) {
104953
+ const modules = await findAdditionalModules(entry, rules);
104954
+ if (outDir) {
104955
+ await writeAdditionalModules(modules, outDir);
104956
+ }
104957
+ const bundleType = getBundleType(entry.format, entry.file);
104958
+ return {
104959
+ modules,
104960
+ dependencies: {},
104961
+ resolvedEntryPointPath: entry.file,
104962
+ bundleType
104963
+ };
104964
+ }
104965
+ __name(noBundleWorker, "noBundleWorker");
104966
+
104955
104967
  // src/deployment-bundle/node-compat.ts
104956
104968
  init_import_meta_url();
104957
104969
  var import_miniflare16 = require("miniflare");
@@ -111376,7 +111388,7 @@ async function fillOpenAPIConfiguration(config, json) {
111376
111388
  if (json && err instanceof ApiError) {
111377
111389
  message = JSON.stringify(err);
111378
111390
  }
111379
- crash("loading Cloudchamber account failed:" + message);
111391
+ crash("Loading account failed: " + message);
111380
111392
  }
111381
111393
  }
111382
111394
  __name(fillOpenAPIConfiguration, "fillOpenAPIConfiguration");
@@ -123464,20 +123476,32 @@ var kvBulkPutCommand = createCommand({
123464
123476
  Expected an array of key-value objects but got type "${typeof content}".`
123465
123477
  );
123466
123478
  }
123479
+ let maxNumberOfErrorsReached = false;
123467
123480
  const errors = [];
123481
+ let maxNumberOfWarningsReached = false;
123468
123482
  const warnings = [];
123469
123483
  for (let i5 = 0; i5 < content.length; i5++) {
123470
123484
  const keyValue = content[i5];
123471
- if (!isKVKeyValue(keyValue)) {
123472
- errors.push(`The item at index ${i5} is ${JSON.stringify(keyValue)}`);
123485
+ if (!isKVKeyValue(keyValue) && !maxNumberOfErrorsReached) {
123486
+ if (errors.length === BATCH_MAX_ERRORS_WARNINGS) {
123487
+ maxNumberOfErrorsReached = true;
123488
+ errors.push("...");
123489
+ } else {
123490
+ errors.push(`The item at index ${i5} is ${JSON.stringify(keyValue)}`);
123491
+ }
123473
123492
  } else {
123474
123493
  const props = unexpectedKVKeyValueProps(keyValue);
123475
- if (props.length > 0) {
123476
- warnings.push(
123477
- `The item at index ${i5} contains unexpected properties: ${JSON.stringify(
123478
- props
123479
- )}.`
123480
- );
123494
+ if (props.length > 0 && !maxNumberOfWarningsReached) {
123495
+ if (warnings.length === BATCH_MAX_ERRORS_WARNINGS) {
123496
+ maxNumberOfWarningsReached = true;
123497
+ warnings.push("...");
123498
+ } else {
123499
+ warnings.push(
123500
+ `The item at index ${i5} contains unexpected properties: ${JSON.stringify(
123501
+ props
123502
+ )}.`
123503
+ );
123504
+ }
123481
123505
  }
123482
123506
  }
123483
123507
  }
@@ -123702,7 +123726,7 @@ var telemetryStatusCommand = createCommand({
123702
123726
  logTelemetryStatus(savedConfig.permission?.enabled ?? true);
123703
123727
  }
123704
123728
  logger.log(
123705
- "To configure telemetry globally on this machine, you can run `wrangler telemetry disable / enable`.\nYou can override this for individual projects with the environment variable `WRANGLER_SEND_METRICS=true/false`.\nLearn more at https://github.com/cloudflare/workers-sdk/tree/main/telemetry.md\n"
123729
+ "To configure telemetry globally on this machine, you can run `wrangler telemetry disable / enable`.\nYou can override this for individual projects with the environment variable `WRANGLER_SEND_METRICS=true/false`.\nLearn more at https://github.com/cloudflare/workers-sdk/tree/main/packages/wrangler/telemetry.md\n"
123706
123730
  );
123707
123731
  }
123708
123732
  });
@@ -127174,7 +127198,7 @@ async function Handler13({
127174
127198
  new URLSearchParams({ env: environment })
127175
127199
  );
127176
127200
  const envDeployments = deployments.filter(
127177
- (d6) => d6.environment === environment
127201
+ (d6) => d6.environment === environment && d6.latest_stage.name === "deploy" && d6.latest_stage.status === "success"
127178
127202
  );
127179
127203
  if (isUrl(deployment)) {
127180
127204
  const { hostname: deploymentHostname } = new URL(deployment);
@@ -147444,9 +147468,9 @@ async function whoami(accountFilter) {
147444
147468
  "You are not authenticated. Please run `wrangler login`."
147445
147469
  );
147446
147470
  }
147447
- if (user.authType === "API Token") {
147471
+ if (user.authType === "User API Token" || user.authType === "Account API Token") {
147448
147472
  logger.log(
147449
- "\u2139\uFE0F The API Token is read from the CLOUDFLARE_API_TOKEN in your environment."
147473
+ "\u2139\uFE0F The API Token is read from the CLOUDFLARE_API_TOKEN environment variable."
147450
147474
  );
147451
147475
  }
147452
147476
  await printUserEmail(user);
@@ -147456,6 +147480,12 @@ async function whoami(accountFilter) {
147456
147480
  }
147457
147481
  __name(whoami, "whoami");
147458
147482
  function printUserEmail(user) {
147483
+ if (user.authType === "Account API Token") {
147484
+ const accountName = user.accounts[0].name;
147485
+ return void logger.log(
147486
+ `\u{1F44B} You are logged in with an ${user.authType}, associated with the account ${source_default.blue(accountName)}.`
147487
+ );
147488
+ }
147459
147489
  if (!user.email) {
147460
147490
  return void logger.log(
147461
147491
  `\u{1F44B} You are logged in with an ${user.authType}. Unable to retrieve email for this user. Are you missing the \`User->User Details->Read\` permission?`
@@ -147479,7 +147509,7 @@ function printTokenPermissions(user) {
147479
147509
  const permissions = user.tokenPermissions?.map((scope) => scope.split(":")) ?? [];
147480
147510
  if (user.authType !== "OAuth Token") {
147481
147511
  return void logger.log(
147482
- `\u{1F513} To see token permissions visit https://dash.cloudflare.com/profile/api-tokens.`
147512
+ `\u{1F513} To see token permissions visit https://dash.cloudflare.com/${user.authType === "User API Token" ? "profile" : user.accounts[0].id}/api-tokens.`
147483
147513
  );
147484
147514
  }
147485
147515
  logger.log(
@@ -147530,18 +147560,45 @@ async function getUserInfo() {
147530
147560
  if (!apiToken) {
147531
147561
  return;
147532
147562
  }
147563
+ const authType = await getAuthType(apiToken);
147533
147564
  const tokenPermissions = await getTokenPermissions();
147534
- const usingEnvAuth = !!getAuthFromEnv();
147535
- const usingGlobalAuthKey = "authKey" in apiToken;
147536
147565
  return {
147537
- apiToken: usingGlobalAuthKey ? apiToken.authKey : apiToken.apiToken,
147538
- authType: usingGlobalAuthKey ? "Global API Key" : usingEnvAuth ? "API Token" : "OAuth Token",
147566
+ apiToken: "authKey" in apiToken ? apiToken.authKey : apiToken.apiToken,
147567
+ authType,
147539
147568
  email: "authEmail" in apiToken ? apiToken.authEmail : await getEmail(),
147540
147569
  accounts: await getAccounts(),
147541
147570
  tokenPermissions
147542
147571
  };
147543
147572
  }
147544
147573
  __name(getUserInfo, "getUserInfo");
147574
+ async function getAuthType(credentials) {
147575
+ if ("authKey" in credentials) {
147576
+ return "Global API Key";
147577
+ }
147578
+ const usingEnvAuth = !!getAuthFromEnv();
147579
+ if (!usingEnvAuth) {
147580
+ return "OAuth Token";
147581
+ }
147582
+ const tokenType = await getTokenType();
147583
+ if (tokenType === "account") {
147584
+ return "Account API Token";
147585
+ } else {
147586
+ return "User API Token";
147587
+ }
147588
+ }
147589
+ __name(getAuthType, "getAuthType");
147590
+ async function getTokenType() {
147591
+ try {
147592
+ await fetchResult("/user/tokens/verify");
147593
+ return "user";
147594
+ } catch (e7) {
147595
+ if (e7.code === 1e3) {
147596
+ return "account";
147597
+ }
147598
+ throw e7;
147599
+ }
147600
+ }
147601
+ __name(getTokenType, "getTokenType");
147545
147602
  async function getEmail() {
147546
147603
  try {
147547
147604
  const { email } = await fetchResult("/user");
@@ -151015,19 +151072,6 @@ function formatTime3(duration) {
151015
151072
  return `(${(duration / 1e3).toFixed(2)} sec)`;
151016
151073
  }
151017
151074
  __name(formatTime3, "formatTime");
151018
- async function noBundleWorker(entry, rules, outDir) {
151019
- const modules = await findAdditionalModules(entry, rules);
151020
- if (outDir) {
151021
- await writeAdditionalModules(modules, outDir);
151022
- }
151023
- return {
151024
- modules,
151025
- dependencies: {},
151026
- resolvedEntryPointPath: entry.file,
151027
- bundleType: getBundleType(entry.format)
151028
- };
151029
- }
151030
- __name(noBundleWorker, "noBundleWorker");
151031
151075
 
151032
151076
  // src/versions/view.ts
151033
151077
  init_import_meta_url();
@@ -154020,7 +154064,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
154020
154064
  resolvedEntryPointPath,
154021
154065
  bundleType,
154022
154066
  ...bundle
154023
- } = props.noBundle ? await noBundleWorker2(props.entry, props.rules, props.outDir) : await bundleWorker(
154067
+ } = props.noBundle ? await noBundleWorker(props.entry, props.rules, props.outDir) : await bundleWorker(
154024
154068
  props.entry,
154025
154069
  typeof destination === "string" ? destination : destination.path,
154026
154070
  {
@@ -154565,20 +154609,6 @@ async function updateQueueConsumers(scriptName, config) {
154565
154609
  return updateConsumers;
154566
154610
  }
154567
154611
  __name(updateQueueConsumers, "updateQueueConsumers");
154568
- async function noBundleWorker2(entry, rules, outDir) {
154569
- const modules = await findAdditionalModules(entry, rules);
154570
- if (outDir) {
154571
- await writeAdditionalModules(modules, outDir);
154572
- }
154573
- const bundleType = getBundleType(entry.format, entry.file);
154574
- return {
154575
- modules,
154576
- dependencies: {},
154577
- resolvedEntryPointPath: entry.file,
154578
- bundleType
154579
- };
154580
- }
154581
- __name(noBundleWorker2, "noBundleWorker");
154582
154612
 
154583
154613
  // src/assets.ts
154584
154614
  init_hash();
@@ -154815,6 +154845,9 @@ function getAssetsBasePath(config, assetsCommandLineArg) {
154815
154845
  return assetsCommandLineArg ? process.cwd() : path65.resolve(path65.dirname(config.configPath ?? "wrangler.toml"));
154816
154846
  }
154817
154847
  __name(getAssetsBasePath, "getAssetsBasePath");
154848
+ var NonExistentAssetsDirError = class extends UserError {
154849
+ };
154850
+ __name(NonExistentAssetsDirError, "NonExistentAssetsDirError");
154818
154851
  function getAssetsOptions(args, config) {
154819
154852
  const assets = args.assets ? { directory: args.assets } : config.assets;
154820
154853
  if (!assets) {
@@ -154836,7 +154869,7 @@ function getAssetsOptions(args, config) {
154836
154869
  const resolvedAssetsPath = path65.resolve(assetsBasePath, directory);
154837
154870
  if (!(0, import_node_fs33.existsSync)(resolvedAssetsPath)) {
154838
154871
  const sourceOfTruthMessage = args.assets ? '"--assets" command line argument' : '"assets.directory" field in your configuration file';
154839
- throw new UserError(
154872
+ throw new NonExistentAssetsDirError(
154840
154873
  `The directory specified by the ${sourceOfTruthMessage} does not exist:
154841
154874
  ${resolvedAssetsPath}`,
154842
154875
  {
@@ -156575,7 +156608,7 @@ var BundlerController = class extends Controller {
156575
156608
  rules: config.build.moduleRules
156576
156609
  });
156577
156610
  const bindings = (await convertBindingsToCfWorkerInitBindings(config.bindings)).bindings;
156578
- const bundleResult = !config.build?.bundle ? await noBundleWorker2(
156611
+ const bundleResult = !config.build?.bundle ? await noBundleWorker(
156579
156612
  entry,
156580
156613
  config.build.moduleRules,
156581
156614
  this.#tmpDir.path
@@ -158264,8 +158297,18 @@ async function getMiniflareOptionsFromConfig(rawConfig, env6, options32) {
158264
158297
  migrations: rawConfig.migrations,
158265
158298
  imagesLocalMode: false
158266
158299
  });
158267
- const persistOptions = getMiniflarePersistOptions(options32.persist);
158300
+ let processedAssetOptions;
158301
+ try {
158302
+ processedAssetOptions = getAssetsOptions({ assets: void 0 }, rawConfig);
158303
+ } catch (e7) {
158304
+ const isNonExistentError = e7 instanceof NonExistentAssetsDirError;
158305
+ if (!isNonExistentError) {
158306
+ throw e7;
158307
+ }
158308
+ }
158309
+ const assetOptions = processedAssetOptions ? buildAssetOptions({ assets: processedAssetOptions }) : {};
158268
158310
  const serviceBindings = await getServiceBindings(bindings.services);
158311
+ const persistOptions = getMiniflarePersistOptions(options32.persist);
158269
158312
  const miniflareOptions = {
158270
158313
  workers: [
158271
158314
  {
@@ -158276,7 +158319,8 @@ async function getMiniflareOptionsFromConfig(rawConfig, env6, options32) {
158276
158319
  serviceBindings: {
158277
158320
  ...serviceBindings,
158278
158321
  ...bindingOptions.serviceBindings
158279
- }
158322
+ },
158323
+ ...assetOptions
158280
158324
  },
158281
158325
  ...externalWorkers
158282
158326
  ],