wrangler 4.155.0 → 4.156.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.
Files changed (2) hide show
  1. package/package.json +14 -14
  2. package/wrangler-dist/cli.js +129 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "4.155.0",
3
+ "version": "4.156.0",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "assembly",
@@ -73,8 +73,8 @@
73
73
  "unenv": "2.0.0-rc.24",
74
74
  "workerd": "1.20261023.1",
75
75
  "@cloudflare/kv-asset-handler": "0.5.0",
76
- "@cloudflare/unenv-preset": "2.16.2",
77
- "miniflare": "5.20261023.2-beta"
76
+ "miniflare": "5.20261023.3-beta",
77
+ "@cloudflare/unenv-preset": "2.16.2"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@aws-sdk/client-s3": "^3.721.0",
@@ -164,22 +164,22 @@
164
164
  "yaml": "^2.8.1",
165
165
  "yargs": "^17.7.2",
166
166
  "zod": "4.6.6",
167
+ "@cloudflare/autoconfig": "0.8.3",
167
168
  "@cloudflare/build-output-utils": "0.9.6",
168
- "@cloudflare/autoconfig": "0.8.2",
169
+ "@cloudflare/cli-shared-helpers": "0.3.0",
169
170
  "@cloudflare/config": "0.29.0",
170
- "@cloudflare/cli-shared-helpers": "0.2.10",
171
- "@cloudflare/containers-shared": "0.23.4",
172
- "@cloudflare/deploy-helpers": "0.24.2",
171
+ "@cloudflare/containers-shared": "0.23.5",
172
+ "@cloudflare/deploy-helpers": "0.24.3",
173
173
  "@cloudflare/pages-functions": "0.1.2",
174
- "@cloudflare/pages-shared": "^0.13.204",
175
- "@cloudflare/remote-bindings": "0.0.55",
176
- "@cloudflare/runtime-types": "0.1.18",
174
+ "@cloudflare/pages-shared": "^0.13.205",
175
+ "@cloudflare/remote-bindings": "0.0.56",
176
+ "@cloudflare/runtime-types": "0.1.19",
177
177
  "@cloudflare/shared-ast-primitives": "1.1.0",
178
- "@cloudflare/workers-auth": "0.15.2",
178
+ "@cloudflare/workers-auth": "0.15.3",
179
179
  "@cloudflare/workers-shared": "0.20.2",
180
- "@cloudflare/workers-tsconfig": "0.0.0",
181
- "@cloudflare/workers-utils": "0.50.0",
182
- "@cloudflare/workflows-shared": "0.15.3"
180
+ "@cloudflare/workers-utils": "0.50.1",
181
+ "@cloudflare/workflows-shared": "0.15.3",
182
+ "@cloudflare/workers-tsconfig": "0.0.0"
183
183
  },
184
184
  "peerDependencies": {
185
185
  "@cloudflare/workers-types": "^5.20261023.1"
@@ -438,7 +438,7 @@ function validateDurableObjectContainerApplications(config2, containers = getDur
438
438
  { telemetryMessage: "no DO defined that matches container class_name" }
439
439
  );
440
440
  }
441
- if (maybeBoundDO?.script_name !== void 0) {
441
+ if (maybeBoundDO?.script_name !== void 0 && maybeBoundDO.script_name !== config2.name) {
442
442
  throw new UserError(
443
443
  `The container ${container.name} is referencing the durable object ${container.class_name}, which appears to be defined on the ${maybeBoundDO.script_name} Worker instead (via the 'script_name' field). You cannot configure a container on a Durable Object that is defined in another Worker.`,
444
444
  {
@@ -68193,7 +68193,7 @@ var name, version2;
68193
68193
  var init_package = __esm({
68194
68194
  "package.json"() {
68195
68195
  name = "wrangler";
68196
- version2 = "4.155.0";
68196
+ version2 = "4.156.0";
68197
68197
  }
68198
68198
  });
68199
68199
 
@@ -140693,6 +140693,19 @@ async function fetchGraphqlResult(complianceConfig, init4 = {}, abortSignal) {
140693
140693
  throw new Error("A request to the Cloudflare API (/graphql) failed.");
140694
140694
  }
140695
140695
  }
140696
+ async function fetchGraphqlResultOrThrow(complianceConfig, init4 = {}) {
140697
+ const { response, status: status2, retryAfterMs } = await fetchInternal(
140698
+ complianceConfig,
140699
+ "/graphql",
140700
+ { ...init4, method: "POST" }
140701
+ );
140702
+ const errors = response.errors ?? [];
140703
+ if (status2 >= 400 || errors.length > 0) {
140704
+ const apiMessage = errors.flatMap((error64) => error64.message ?? []).join("; ") || `HTTP ${status2} with no error message`;
140705
+ throw new GraphQLAnalyticsError(status2, apiMessage, retryAfterMs);
140706
+ }
140707
+ return response;
140708
+ }
140696
140709
  async function fetchListResult2(complianceConfig, resource, init4 = {}, queryParams) {
140697
140710
  const credentials = await resolveCredentials(complianceConfig);
140698
140711
  return fetchListResultBase(
@@ -140773,6 +140786,7 @@ async function fetchCursorPage(complianceConfig, resource, init4 = {}, queryPara
140773
140786
  }
140774
140787
  return results;
140775
140788
  }
140789
+ var GraphQLAnalyticsError;
140776
140790
  var init_cfetch2 = __esm({
140777
140791
  "src/cfetch/index.ts"() {
140778
140792
  init_import_meta_url();
@@ -140783,6 +140797,25 @@ var init_cfetch2 = __esm({
140783
140797
  init_internal();
140784
140798
  __name(fetchResult2, "fetchResult");
140785
140799
  __name(fetchGraphqlResult, "fetchGraphqlResult");
140800
+ GraphQLAnalyticsError = class extends APIError {
140801
+ static {
140802
+ __name(this, "GraphQLAnalyticsError");
140803
+ }
140804
+ reason;
140805
+ apiMessage;
140806
+ constructor(status2, apiMessage, retryAfterMs) {
140807
+ const reason = status2 === 429 || /rate limiter budget depleted/i.test(apiMessage) ? "rate-limited" : status2 === 401 || status2 === 403 ? "unauthorized" : "other";
140808
+ super({
140809
+ text: `The GraphQL Analytics API returned an error: ${apiMessage}`,
140810
+ status: status2,
140811
+ retryAfterMs,
140812
+ telemetryMessage: `cfetch graphql ${reason}`
140813
+ });
140814
+ this.reason = reason;
140815
+ this.apiMessage = apiMessage;
140816
+ }
140817
+ };
140818
+ __name(fetchGraphqlResultOrThrow, "fetchGraphqlResultOrThrow");
140786
140819
  __name(fetchListResult2, "fetchListResult");
140787
140820
  __name(fetchPagedListResult2, "fetchPagedListResult");
140788
140821
  __name(fetchCursorPage, "fetchCursorPage");
@@ -170866,7 +170899,7 @@ async function prepareDurableObjectContainerApplications(config2, durableObjectC
170866
170899
  versionsUploadCommand: versionsUploadCommand2
170867
170900
  }) {
170868
170901
  validateDurableObjectContainerApplications(
170869
- config2,
170902
+ { ...config2, name: scriptName },
170870
170903
  durableObjectContainerConfig,
170871
170904
  configFileName(config2.configPath, config2.userConfigPath)
170872
170905
  );
@@ -186922,7 +186955,7 @@ var init_dist14 = __esm({
186922
186955
  init_wrapper();
186923
186956
  init_create_worker_upload_form();
186924
186957
  import_undici14 = __toESM(require_undici(), 1);
186925
- version3 = "0.0.55";
186958
+ version3 = "0.0.56";
186926
186959
  NoDefaultValueProvided2 = class extends UserError {
186927
186960
  static {
186928
186961
  __name(this, "NoDefaultValueProvided");
@@ -205363,7 +205396,7 @@ var init_config7 = __esm({
205363
205396
  const maybeBoundDO = config2.durable_objects.bindings.find(
205364
205397
  (durableObject) => durableObject.class_name === className
205365
205398
  );
205366
- if (maybeBoundDO && maybeBoundDO.script_name !== void 0) {
205399
+ if (maybeBoundDO?.script_name !== void 0 && maybeBoundDO.script_name !== config2.name) {
205367
205400
  throw new UserError(
205368
205401
  `The container ${container.name} is referencing the durable object ${className}, which appears to be defined on the ${maybeBoundDO.script_name} Worker instead (via the 'script_name' field). You cannot configure a container on a Durable Object that is defined in another Worker.`,
205369
205402
  {
@@ -221527,7 +221560,7 @@ async function mergeDeployConfigArgs(args, config2) {
221527
221560
  }));
221528
221561
  const routes = args.routes ? applyZoneArgsToRoutes(args.routes, args) : config2.routes ?? (config2.route ? [config2.route] : []);
221529
221562
  const normalizedContainerConfig = await getNormalizedContainerOptions(
221530
- config2,
221563
+ { ...config2, name: shared.name },
221531
221564
  {
221532
221565
  containersRollout: args.containersRollout,
221533
221566
  dryRun: shared.dryRun
@@ -239919,11 +239952,45 @@ function getDurationDates(durationString) {
239919
239952
  }
239920
239953
  return [startDate.toISOString(), endDate.toISOString()];
239921
239954
  }
239955
+ function toD1InsightsUserError(error64, accountId) {
239956
+ switch (error64.reason) {
239957
+ case "rate-limited":
239958
+ return new UserError(
239959
+ esm_default`
239960
+ Could not get D1 insights: the GraphQL Analytics API rate limited the request (${error64.apiMessage}).
239961
+
239962
+ ${error64.retryAfterMs === void 0 ? "The rate limit resets within 5 minutes: wait" : `Wait ${Math.ceil(error64.retryAfterMs / 1e3)} seconds`} before running \`wrangler d1 insights\` again. To use less of the rate limit budget, pass a database name, a shorter --time-period, or a smaller --limit.
239963
+ See https://developers.cloudflare.com/analytics/graphql-api/limits/
239964
+ `,
239965
+ { telemetryMessage: "d1 insights graphql rate limited", cause: error64 }
239966
+ );
239967
+ case "unauthorized":
239968
+ return new UserError(
239969
+ esm_default`
239970
+ Could not get D1 insights: not allowed to read analytics for account ${accountId} (${error64.apiMessage}).
239971
+
239972
+ \`wrangler d1 insights\` needs the "Account Analytics: Read" permission on this account. If you use CLOUDFLARE_API_TOKEN, add that permission to the token at https://dash.cloudflare.com/profile/api-tokens. Otherwise run \`wrangler login\` again, and check that CLOUDFLARE_ACCOUNT_ID or \`account_id\` points at an account you are a member of.
239973
+ `,
239974
+ { telemetryMessage: "d1 insights graphql unauthorized", cause: error64 }
239975
+ );
239976
+ case "other":
239977
+ return new UserError(
239978
+ esm_default`
239979
+ Could not get D1 insights: the GraphQL Analytics API returned an error (${error64.apiMessage}).
239980
+
239981
+ Check the --time-period, --limit and sort options, then run \`wrangler d1 insights\` again.
239982
+ See https://developers.cloudflare.com/analytics/graphql-api/errors/
239983
+ `,
239984
+ { telemetryMessage: "d1 insights graphql error", cause: error64 }
239985
+ );
239986
+ }
239987
+ }
239922
239988
  var cliOptionToGraphQLOption, d1InsightsCommand;
239923
239989
  var init_insights3 = __esm({
239924
239990
  "src/d1/insights.ts"() {
239925
239991
  init_import_meta_url();
239926
239992
  init_src();
239993
+ init_esm();
239927
239994
  init_cfetch2();
239928
239995
  init_create_command();
239929
239996
  init_logger2();
@@ -239936,9 +240003,10 @@ var init_insights3 = __esm({
239936
240003
  count: "count"
239937
240004
  };
239938
240005
  __name(getDurationDates, "getDurationDates");
240006
+ __name(toD1InsightsUserError, "toD1InsightsUserError");
239939
240007
  d1InsightsCommand = createCommand({
239940
240008
  metadata: {
239941
- description: "Get information about the queries run on a D1 database",
240009
+ description: "Get information about the queries run on a D1 database, or on all D1 databases in the account",
239942
240010
  epilogue: "This command acts on remote D1 Databases.",
239943
240011
  status: "experimental",
239944
240012
  owner: "Product: D1"
@@ -239950,8 +240018,7 @@ var init_insights3 = __esm({
239950
240018
  args: {
239951
240019
  name: {
239952
240020
  type: "string",
239953
- demandOption: true,
239954
- description: "The name of the DB"
240021
+ description: "The name or binding of the DB. Omit to get insights for every D1 database in the account"
239955
240022
  },
239956
240023
  "time-period": {
239957
240024
  type: "string",
@@ -239997,12 +240064,12 @@ var init_insights3 = __esm({
239997
240064
  positionalArgs: ["name"],
239998
240065
  async handler({ name: name2, json: json2, limit: limit2, timePeriod, sortType, sortBy, sortDirection }, { config: config2 }) {
239999
240066
  const accountId = await requireAuth(config2);
240000
- const db = await getDatabaseByNameOrBinding(config2, accountId, name2);
240067
+ const db = name2 === void 0 ? void 0 : await getDatabaseByNameOrBinding(config2, accountId, name2);
240001
240068
  const output2 = [];
240002
240069
  const [startDate, endDate] = getDurationDates(timePeriod);
240003
240070
  const parsedSortBy = cliOptionToGraphQLOption[sortBy];
240004
240071
  const orderByClause = parsedSortBy === "count" ? `${parsedSortBy}_${sortDirection}` : `${sortType}_${parsedSortBy}_${sortDirection}`;
240005
- const graphqlQueriesResult = await fetchGraphqlResult(config2, {
240072
+ const graphqlQueriesResult = await fetchGraphqlResultOrThrow(config2, {
240006
240073
  method: "POST",
240007
240074
  body: JSON.stringify({
240008
240075
  query: `query getD1QueriesOverviewQuery($accountTag: string, $filter: ZoneWorkersRequestsFilter_InputObject) {
@@ -240024,6 +240091,7 @@ var init_insights3 = __esm({
240024
240091
  count
240025
240092
  dimensions {
240026
240093
  query
240094
+ databaseId
240027
240095
  }
240028
240096
  }
240029
240097
  }
@@ -240037,7 +240105,7 @@ var init_insights3 = __esm({
240037
240105
  {
240038
240106
  datetimeHour_geq: startDate,
240039
240107
  datetimeHour_leq: endDate,
240040
- databaseId: db.uuid
240108
+ ...db ? { databaseId: db.uuid } : {}
240041
240109
  }
240042
240110
  ]
240043
240111
  }
@@ -240046,6 +240114,11 @@ var init_insights3 = __esm({
240046
240114
  headers: {
240047
240115
  "Content-Type": "application/json"
240048
240116
  }
240117
+ }).catch((err) => {
240118
+ if (err instanceof GraphQLAnalyticsError) {
240119
+ throw toD1InsightsUserError(err, accountId);
240120
+ }
240121
+ throw err;
240049
240122
  });
240050
240123
  graphqlQueriesResult?.data?.viewer?.accounts[0]?.d1QueriesAdaptiveGroups?.forEach(
240051
240124
  (row) => {
@@ -240061,7 +240134,8 @@ var init_insights3 = __esm({
240061
240134
  avgDurationMs: row?.avg?.queryDurationMs ?? 0,
240062
240135
  totalDurationMs: row?.sum?.queryDurationMs ?? 0,
240063
240136
  numberOfTimesRun: row?.count ?? 0,
240064
- queryEfficiency: row?.avg?.rowsReturned && row?.avg?.rowsRead ? row?.avg?.rowsReturned / row?.avg?.rowsRead : 0
240137
+ queryEfficiency: row?.avg?.rowsReturned && row?.avg?.rowsRead ? row?.avg?.rowsReturned / row?.avg?.rowsRead : 0,
240138
+ ...db ? {} : { databaseId: row.dimensions.databaseId ?? null }
240065
240139
  });
240066
240140
  }
240067
240141
  );
@@ -296192,6 +296266,19 @@ async function getDetailsForAutoConfig({
296192
296266
  configured
296193
296267
  });
296194
296268
  }
296269
+ if (framework.id === staticFramework.id && (context2.isNonInteractiveOrCI?.() ?? false) && path29.resolve(projectPath, outputDir) === path29.resolve(projectPath) && (await getPathStats(path29.join(projectPath, "functions")))?.isDirectory()) {
296270
+ const configFile = target === "cf" ? `a \`${CLOUDFLARE_CONFIG_FILE}\` file` : "a Wrangler configuration file";
296271
+ throw new AutoConfigDetectionError(
296272
+ `This project has a \`functions\` directory and static files in its root, which looks like a Cloudflare Pages project using Pages Functions. Automatic configuration cannot migrate Pages Functions to Workers yet, and deploying the project root as static assets would leave the Functions undeployed.
296273
+ If \`functions\` contains Pages Functions, move the static files into a subdirectory (for example \`public/\`) and deploy with \`wrangler pages deploy public --project-name <name>\`, or migrate the Functions to a Worker: https://developers.cloudflare.com/workers/static-assets/migration-guides/migrate-from-pages/
296274
+ If \`functions\` is not Pages Functions, move the static files into a subdirectory or add ${configFile} for the Worker.`,
296275
+ {
296276
+ telemetryMessage: "autoconfig details pages functions with root assets",
296277
+ frameworkId: framework.id,
296278
+ configured
296279
+ }
296280
+ );
296281
+ }
296195
296282
  return {
296196
296283
  ...baseDetails,
296197
296284
  outputDir,
@@ -296321,7 +296408,7 @@ var init_details2 = __esm({
296321
296408
  __name(confirmAutoConfigDetails, "confirmAutoConfigDetails");
296322
296409
  }
296323
296410
  });
296324
- function maybeAppendWranglerToGitIgnoreLikeFile(filePath) {
296411
+ function maybeAppendWranglerToGitIgnoreLikeFile(filePath, { additionalEntries = [], requireEnvWildcard = false } = {}) {
296325
296412
  const filePreExisted = fs14.existsSync(filePath);
296326
296413
  if (!filePreExisted) fs14.writeFileSync(filePath, "");
296327
296414
  const existingGitIgnoreContent = readFileSync(filePath);
@@ -296330,8 +296417,10 @@ function maybeAppendWranglerToGitIgnoreLikeFile(filePath) {
296330
296417
  if (!hasDotWrangler) wranglerGitIgnoreFilesToAdd.push(".wrangler");
296331
296418
  if (!existingGitIgnoreContent.match(/^\/?\.dev\.vars\*(\s|$)/m)) wranglerGitIgnoreFilesToAdd.push(".dev.vars*");
296332
296419
  if (!existingGitIgnoreContent.match(/^!\/?\.dev\.vars\.example(\s|$)/m)) wranglerGitIgnoreFilesToAdd.push("!.dev.vars.example");
296333
- if (!existingGitIgnoreContent.match(/^\/?\.env\*?(\..*?)?(\s|$)/m)) wranglerGitIgnoreFilesToAdd.push(".env*");
296420
+ if (!existingGitIgnoreContent.match(requireEnvWildcard ? /^\.env\*(\s|$)/m : /^\/?\.env\*?(\..*?)?(\s|$)/m)) wranglerGitIgnoreFilesToAdd.push(".env*");
296334
296421
  if (!existingGitIgnoreContent.match(/^!\/?\.env\.example(\s|$)/m)) wranglerGitIgnoreFilesToAdd.push("!.env.example");
296422
+ const existingLines = new Set(existingGitIgnoreContent.split(/\r?\n/).map((line) => line.trim()));
296423
+ for (const entry of additionalEntries) if (!existingLines.has(entry) && !wranglerGitIgnoreFilesToAdd.includes(entry)) wranglerGitIgnoreFilesToAdd.push(entry);
296335
296424
  if (wranglerGitIgnoreFilesToAdd.length === 0) return;
296336
296425
  const s8 = spinner();
296337
296426
  s8.start(`Adding Wrangler files to the ${path29.basename(filePath)} file`);
@@ -296358,12 +296447,22 @@ function directoryExists(path$1) {
296358
296447
  throw new Error(error64);
296359
296448
  }
296360
296449
  }
296450
+ var PROJECT_ROOT_ASSETS_IGNORE_ENTRIES;
296361
296451
  var init_gitignore = __esm({
296362
296452
  "../cli/dist/gitignore.mjs"() {
296363
296453
  init_import_meta_url();
296364
296454
  init_colors();
296365
296455
  init_interactive();
296366
296456
  init_src();
296457
+ PROJECT_ROOT_ASSETS_IGNORE_ENTRIES = [
296458
+ "/_worker.js",
296459
+ "/_routes.json",
296460
+ "/functions",
296461
+ "node_modules",
296462
+ ".git",
296463
+ ".DS_Store",
296464
+ ".npmrc"
296465
+ ];
296367
296466
  __name(maybeAppendWranglerToGitIgnoreLikeFile, "maybeAppendWranglerToGitIgnoreLikeFile");
296368
296467
  __name(maybeAppendWranglerToGitIgnore, "maybeAppendWranglerToGitIgnore");
296369
296468
  __name(directoryExists, "directoryExists");
@@ -296641,10 +296740,23 @@ ${JSON.stringify(autoConfigDetails, null, 2)}...`
296641
296740
  }
296642
296741
  }
296643
296742
  maybeAppendWranglerToGitIgnore(autoConfigDetails.projectPath);
296644
- if (autoConfigDetails.outputDir === autoConfigDetails.projectPath) {
296743
+ const assetsDirectory = configurationResults.buildConfig?.assetsDirectory;
296744
+ if (assetsDirectory !== void 0 && path29.resolve(autoConfigDetails.projectPath, assetsDirectory) === path29.resolve(autoConfigDetails.projectPath)) {
296645
296745
  maybeAppendWranglerToGitIgnoreLikeFile(
296646
- `${autoConfigDetails.projectPath}/.assetsignore`
296746
+ `${autoConfigDetails.projectPath}/.assetsignore`,
296747
+ {
296748
+ additionalEntries: PROJECT_ROOT_ASSETS_IGNORE_ENTRIES,
296749
+ requireEnvWildcard: true
296750
+ }
296751
+ );
296752
+ const pagesServerCode = workerConfig?.entrypoint ? [] : ["functions", "_worker.js"].filter(
296753
+ (name2) => fs14.existsSync(path29.resolve(autoConfigDetails.projectPath, name2))
296647
296754
  );
296755
+ if (pagesServerCode.length > 0) {
296756
+ context2.logger.warn(
296757
+ `${pagesServerCode.map((name2) => `\`${name2}\``).join(" and ")} in the project root will not be deployed: the project is configured as static assets, so Pages server code is excluded from the upload (via .assetsignore) and is not run. To keep it, migrate it to a Worker: https://developers.cloudflare.com/workers/static-assets/migration-guides/migrate-from-pages/`
296758
+ );
296759
+ }
296648
296760
  }
296649
296761
  if (buildCommand3 && runBuild2) {
296650
296762
  await context2.runCommand(