wrangler 3.114.10 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "3.114.10",
3
+ "version": "3.114.11",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -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.10";
81453
+ var version = "3.114.11";
81454
81454
 
81455
81455
  // src/environment-variables/misc-variables.ts
81456
81456
  init_import_meta_url();
@@ -101185,6 +101185,7 @@ var import_miniflare14 = require("miniflare");
101185
101185
  var import_undici4 = __toESM(require_undici());
101186
101186
  var API_MAX = 1e4;
101187
101187
  var BATCH_KEY_MAX = API_MAX / 10;
101188
+ var BATCH_MAX_ERRORS_WARNINGS = 12;
101188
101189
  async function createKVNamespace(accountId, title) {
101189
101190
  const response = await fetchResult(
101190
101191
  `/accounts/${accountId}/storage/kv/namespaces`,
@@ -123475,20 +123476,32 @@ var kvBulkPutCommand = createCommand({
123475
123476
  Expected an array of key-value objects but got type "${typeof content}".`
123476
123477
  );
123477
123478
  }
123479
+ let maxNumberOfErrorsReached = false;
123478
123480
  const errors = [];
123481
+ let maxNumberOfWarningsReached = false;
123479
123482
  const warnings = [];
123480
123483
  for (let i5 = 0; i5 < content.length; i5++) {
123481
123484
  const keyValue = content[i5];
123482
- if (!isKVKeyValue(keyValue)) {
123483
- 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
+ }
123484
123492
  } else {
123485
123493
  const props = unexpectedKVKeyValueProps(keyValue);
123486
- if (props.length > 0) {
123487
- warnings.push(
123488
- `The item at index ${i5} contains unexpected properties: ${JSON.stringify(
123489
- props
123490
- )}.`
123491
- );
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
+ }
123492
123505
  }
123493
123506
  }
123494
123507
  }
@@ -127185,7 +127198,7 @@ async function Handler13({
127185
127198
  new URLSearchParams({ env: environment })
127186
127199
  );
127187
127200
  const envDeployments = deployments.filter(
127188
- (d6) => d6.environment === environment
127201
+ (d6) => d6.environment === environment && d6.latest_stage.name === "deploy" && d6.latest_stage.status === "success"
127189
127202
  );
127190
127203
  if (isUrl(deployment)) {
127191
127204
  const { hostname: deploymentHostname } = new URL(deployment);
@@ -147455,9 +147468,9 @@ async function whoami(accountFilter) {
147455
147468
  "You are not authenticated. Please run `wrangler login`."
147456
147469
  );
147457
147470
  }
147458
- if (user.authType === "API Token") {
147471
+ if (user.authType === "User API Token" || user.authType === "Account API Token") {
147459
147472
  logger.log(
147460
- "\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."
147461
147474
  );
147462
147475
  }
147463
147476
  await printUserEmail(user);
@@ -147467,6 +147480,12 @@ async function whoami(accountFilter) {
147467
147480
  }
147468
147481
  __name(whoami, "whoami");
147469
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
+ }
147470
147489
  if (!user.email) {
147471
147490
  return void logger.log(
147472
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?`
@@ -147490,7 +147509,7 @@ function printTokenPermissions(user) {
147490
147509
  const permissions = user.tokenPermissions?.map((scope) => scope.split(":")) ?? [];
147491
147510
  if (user.authType !== "OAuth Token") {
147492
147511
  return void logger.log(
147493
- `\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.`
147494
147513
  );
147495
147514
  }
147496
147515
  logger.log(
@@ -147541,18 +147560,45 @@ async function getUserInfo() {
147541
147560
  if (!apiToken) {
147542
147561
  return;
147543
147562
  }
147563
+ const authType = await getAuthType(apiToken);
147544
147564
  const tokenPermissions = await getTokenPermissions();
147545
- const usingEnvAuth = !!getAuthFromEnv();
147546
- const usingGlobalAuthKey = "authKey" in apiToken;
147547
147565
  return {
147548
- apiToken: usingGlobalAuthKey ? apiToken.authKey : apiToken.apiToken,
147549
- authType: usingGlobalAuthKey ? "Global API Key" : usingEnvAuth ? "API Token" : "OAuth Token",
147566
+ apiToken: "authKey" in apiToken ? apiToken.authKey : apiToken.apiToken,
147567
+ authType,
147550
147568
  email: "authEmail" in apiToken ? apiToken.authEmail : await getEmail(),
147551
147569
  accounts: await getAccounts(),
147552
147570
  tokenPermissions
147553
147571
  };
147554
147572
  }
147555
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");
147556
147602
  async function getEmail() {
147557
147603
  try {
147558
147604
  const { email } = await fetchResult("/user");
@@ -154799,6 +154845,9 @@ function getAssetsBasePath(config, assetsCommandLineArg) {
154799
154845
  return assetsCommandLineArg ? process.cwd() : path65.resolve(path65.dirname(config.configPath ?? "wrangler.toml"));
154800
154846
  }
154801
154847
  __name(getAssetsBasePath, "getAssetsBasePath");
154848
+ var NonExistentAssetsDirError = class extends UserError {
154849
+ };
154850
+ __name(NonExistentAssetsDirError, "NonExistentAssetsDirError");
154802
154851
  function getAssetsOptions(args, config) {
154803
154852
  const assets = args.assets ? { directory: args.assets } : config.assets;
154804
154853
  if (!assets) {
@@ -154820,7 +154869,7 @@ function getAssetsOptions(args, config) {
154820
154869
  const resolvedAssetsPath = path65.resolve(assetsBasePath, directory);
154821
154870
  if (!(0, import_node_fs33.existsSync)(resolvedAssetsPath)) {
154822
154871
  const sourceOfTruthMessage = args.assets ? '"--assets" command line argument' : '"assets.directory" field in your configuration file';
154823
- throw new UserError(
154872
+ throw new NonExistentAssetsDirError(
154824
154873
  `The directory specified by the ${sourceOfTruthMessage} does not exist:
154825
154874
  ${resolvedAssetsPath}`,
154826
154875
  {
@@ -158248,8 +158297,18 @@ async function getMiniflareOptionsFromConfig(rawConfig, env6, options32) {
158248
158297
  migrations: rawConfig.migrations,
158249
158298
  imagesLocalMode: false
158250
158299
  });
158251
- 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 }) : {};
158252
158310
  const serviceBindings = await getServiceBindings(bindings.services);
158311
+ const persistOptions = getMiniflarePersistOptions(options32.persist);
158253
158312
  const miniflareOptions = {
158254
158313
  workers: [
158255
158314
  {
@@ -158260,7 +158319,8 @@ async function getMiniflareOptionsFromConfig(rawConfig, env6, options32) {
158260
158319
  serviceBindings: {
158261
158320
  ...serviceBindings,
158262
158321
  ...bindingOptions.serviceBindings
158263
- }
158322
+ },
158323
+ ...assetOptions
158264
158324
  },
158265
158325
  ...externalWorkers
158266
158326
  ],