@cloudflare/workers-utils 0.25.1 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2,14 +2,15 @@ export { assertNever, constructWranglerConfig, getTodaysCompatDate, isCompatDate
2
2
  import { getGlobalConfigPath } from './chunk-OTBYAUQ6.mjs';
3
3
  export { getGlobalConfigPath, getGlobalWranglerCachePath } from './chunk-OTBYAUQ6.mjs';
4
4
  export { MetricsRegistry } from './chunk-TJ6ANXA2.mjs';
5
- import { partitionExports, UserError, isRedirectedRawConfig, dedent, configFileName, formatConfigSnippet, FatalError, ParseError, parseJSON, APIError, parsePackageJSON, readFileSync as readFileSync$1, parseTOML, modify, applyEdits, format, dist_default, parseJSONC } from './chunk-27EBTAT2.mjs';
6
- export { APIError, CommandLineArgsError, DeprecationError, ENVIRONMENT_TAG_PREFIX, FatalError, INHERIT_SYMBOL, JSON_CONFIG_FORMATS, JsonFriendlyFatalError, MissingConfigError, PATH_TO_DEPLOY_CONFIG, ParseError, SERVICE_TAG_PREFIX, UserError, configFileName, configFormat, createFatalError, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, indexLocation, isRedirectedConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, resolveWranglerConfigPath, searchLocation } from './chunk-27EBTAT2.mjs';
5
+ import { partitionExports, UserError, dedent, isRedirectedRawConfig, configFileName, formatConfigSnippet, FatalError, parsePackageJSON, readFileSync, ParseError, parseJSON, APIError, dir, parseTOML, modify, applyEdits, format, dist_default, parseJSONC } from './chunk-XPMIK7N6.mjs';
6
+ export { APIError, CommandLineArgsError, DeprecationError, ENVIRONMENT_TAG_PREFIX, FatalError, INHERIT_SYMBOL, JSON_CONFIG_FORMATS, JsonFriendlyFatalError, MissingConfigError, PATH_TO_DEPLOY_CONFIG, ParseError, SERVICE_TAG_PREFIX, UserError, configFileName, configFormat, createFatalError, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, indexLocation, isRedirectedConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, resolveWranglerConfigPath, searchLocation } from './chunk-XPMIK7N6.mjs';
7
7
  import { isDirectory, removeDirSync } from './chunk-OC543JY3.mjs';
8
8
  export { isDirectory, removeDir, removeDirSync } from './chunk-OC543JY3.mjs';
9
- import { __commonJS, __require, __name, __toESM } from './chunk-DDRU76YD.mjs';
10
- import fs2, { accessSync, constants, writeFileSync, renameSync, existsSync, unlinkSync, mkdirSync, chmodSync, readFileSync } from 'node:fs';
9
+ import { __commonJS, __name, __require, __toESM } from './chunk-DDRU76YD.mjs';
10
+ import fs2, { statSync, accessSync, constants, writeFileSync, renameSync, existsSync, unlinkSync, mkdirSync, chmodSync, readFileSync as readFileSync$1 } from 'node:fs';
11
11
  import assert from 'node:assert';
12
- import path2, { join, dirname, basename, resolve } from 'node:path';
12
+ import * as path2 from 'node:path';
13
+ import path2__default, { join, dirname, basename, resolve } from 'node:path';
13
14
  import { execFileSync, spawn } from 'node:child_process';
14
15
  import { createHash } from 'node:crypto';
15
16
  import { arch } from 'node:os';
@@ -18,13 +19,464 @@ import { URLSearchParams } from 'node:url';
18
19
  import * as timersPromises from 'node:timers/promises';
19
20
  import { setTimeout as setTimeout$1 } from 'node:timers/promises';
20
21
 
22
+ // ../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/vendors.json
23
+ var require_vendors = __commonJS({
24
+ "../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/vendors.json"(exports, module) {
25
+ module.exports = [
26
+ {
27
+ name: "Agola CI",
28
+ constant: "AGOLA",
29
+ env: "AGOLA_GIT_REF",
30
+ pr: "AGOLA_PULL_REQUEST_ID"
31
+ },
32
+ {
33
+ name: "Alpic",
34
+ constant: "ALPIC",
35
+ env: "ALPIC_HOST"
36
+ },
37
+ {
38
+ name: "Appcircle",
39
+ constant: "APPCIRCLE",
40
+ env: "AC_APPCIRCLE",
41
+ pr: {
42
+ env: "AC_GIT_PR",
43
+ ne: "false"
44
+ }
45
+ },
46
+ {
47
+ name: "AppVeyor",
48
+ constant: "APPVEYOR",
49
+ env: "APPVEYOR",
50
+ pr: "APPVEYOR_PULL_REQUEST_NUMBER"
51
+ },
52
+ {
53
+ name: "AWS CodeBuild",
54
+ constant: "CODEBUILD",
55
+ env: "CODEBUILD_BUILD_ARN",
56
+ pr: {
57
+ env: "CODEBUILD_WEBHOOK_EVENT",
58
+ any: [
59
+ "PULL_REQUEST_CREATED",
60
+ "PULL_REQUEST_UPDATED",
61
+ "PULL_REQUEST_REOPENED"
62
+ ]
63
+ }
64
+ },
65
+ {
66
+ name: "Azure Pipelines",
67
+ constant: "AZURE_PIPELINES",
68
+ env: "TF_BUILD",
69
+ pr: {
70
+ BUILD_REASON: "PullRequest"
71
+ }
72
+ },
73
+ {
74
+ name: "Bamboo",
75
+ constant: "BAMBOO",
76
+ env: "bamboo_planKey"
77
+ },
78
+ {
79
+ name: "Bitbucket Pipelines",
80
+ constant: "BITBUCKET",
81
+ env: "BITBUCKET_COMMIT",
82
+ pr: "BITBUCKET_PR_ID"
83
+ },
84
+ {
85
+ name: "Bitrise",
86
+ constant: "BITRISE",
87
+ env: "BITRISE_IO",
88
+ pr: "BITRISE_PULL_REQUEST"
89
+ },
90
+ {
91
+ name: "Buddy",
92
+ constant: "BUDDY",
93
+ env: "BUDDY_WORKSPACE_ID",
94
+ pr: "BUDDY_EXECUTION_PULL_REQUEST_ID"
95
+ },
96
+ {
97
+ name: "Buildkite",
98
+ constant: "BUILDKITE",
99
+ env: "BUILDKITE",
100
+ pr: {
101
+ env: "BUILDKITE_PULL_REQUEST",
102
+ ne: "false"
103
+ }
104
+ },
105
+ {
106
+ name: "CircleCI",
107
+ constant: "CIRCLE",
108
+ env: "CIRCLECI",
109
+ pr: "CIRCLE_PULL_REQUEST"
110
+ },
111
+ {
112
+ name: "Cirrus CI",
113
+ constant: "CIRRUS",
114
+ env: "CIRRUS_CI",
115
+ pr: "CIRRUS_PR"
116
+ },
117
+ {
118
+ name: "Cloudflare Pages",
119
+ constant: "CLOUDFLARE_PAGES",
120
+ env: "CF_PAGES"
121
+ },
122
+ {
123
+ name: "Cloudflare Workers",
124
+ constant: "CLOUDFLARE_WORKERS",
125
+ env: "WORKERS_CI"
126
+ },
127
+ {
128
+ name: "Codefresh",
129
+ constant: "CODEFRESH",
130
+ env: "CF_BUILD_ID",
131
+ pr: {
132
+ any: [
133
+ "CF_PULL_REQUEST_NUMBER",
134
+ "CF_PULL_REQUEST_ID"
135
+ ]
136
+ }
137
+ },
138
+ {
139
+ name: "Codemagic",
140
+ constant: "CODEMAGIC",
141
+ env: "CM_BUILD_ID",
142
+ pr: "CM_PULL_REQUEST"
143
+ },
144
+ {
145
+ name: "Codeship",
146
+ constant: "CODESHIP",
147
+ env: {
148
+ CI_NAME: "codeship"
149
+ }
150
+ },
151
+ {
152
+ name: "Drone",
153
+ constant: "DRONE",
154
+ env: "DRONE",
155
+ pr: {
156
+ DRONE_BUILD_EVENT: "pull_request"
157
+ }
158
+ },
159
+ {
160
+ name: "dsari",
161
+ constant: "DSARI",
162
+ env: "DSARI"
163
+ },
164
+ {
165
+ name: "Earthly",
166
+ constant: "EARTHLY",
167
+ env: "EARTHLY_CI"
168
+ },
169
+ {
170
+ name: "Expo Application Services",
171
+ constant: "EAS",
172
+ env: "EAS_BUILD"
173
+ },
174
+ {
175
+ name: "Gerrit",
176
+ constant: "GERRIT",
177
+ env: "GERRIT_PROJECT"
178
+ },
179
+ {
180
+ name: "Gitea Actions",
181
+ constant: "GITEA_ACTIONS",
182
+ env: "GITEA_ACTIONS"
183
+ },
184
+ {
185
+ name: "GitHub Actions",
186
+ constant: "GITHUB_ACTIONS",
187
+ env: "GITHUB_ACTIONS",
188
+ pr: {
189
+ GITHUB_EVENT_NAME: "pull_request"
190
+ }
191
+ },
192
+ {
193
+ name: "GitLab CI",
194
+ constant: "GITLAB",
195
+ env: "GITLAB_CI",
196
+ pr: "CI_MERGE_REQUEST_ID"
197
+ },
198
+ {
199
+ name: "GoCD",
200
+ constant: "GOCD",
201
+ env: "GO_PIPELINE_LABEL"
202
+ },
203
+ {
204
+ name: "Google Cloud Build",
205
+ constant: "GOOGLE_CLOUD_BUILD",
206
+ env: "BUILDER_OUTPUT"
207
+ },
208
+ {
209
+ name: "Harness CI",
210
+ constant: "HARNESS",
211
+ env: "HARNESS_BUILD_ID"
212
+ },
213
+ {
214
+ name: "Heroku",
215
+ constant: "HEROKU",
216
+ env: {
217
+ env: "NODE",
218
+ includes: "/app/.heroku/node/bin/node"
219
+ }
220
+ },
221
+ {
222
+ name: "Hudson",
223
+ constant: "HUDSON",
224
+ env: "HUDSON_URL"
225
+ },
226
+ {
227
+ name: "Jenkins",
228
+ constant: "JENKINS",
229
+ env: [
230
+ "JENKINS_URL",
231
+ "BUILD_ID"
232
+ ],
233
+ pr: {
234
+ any: [
235
+ "ghprbPullId",
236
+ "CHANGE_ID"
237
+ ]
238
+ }
239
+ },
240
+ {
241
+ name: "LayerCI",
242
+ constant: "LAYERCI",
243
+ env: "LAYERCI",
244
+ pr: "LAYERCI_PULL_REQUEST"
245
+ },
246
+ {
247
+ name: "Magnum CI",
248
+ constant: "MAGNUM",
249
+ env: "MAGNUM"
250
+ },
251
+ {
252
+ name: "Netlify CI",
253
+ constant: "NETLIFY",
254
+ env: "NETLIFY",
255
+ pr: {
256
+ env: "PULL_REQUEST",
257
+ ne: "false"
258
+ }
259
+ },
260
+ {
261
+ name: "Nevercode",
262
+ constant: "NEVERCODE",
263
+ env: "NEVERCODE",
264
+ pr: {
265
+ env: "NEVERCODE_PULL_REQUEST",
266
+ ne: "false"
267
+ }
268
+ },
269
+ {
270
+ name: "Prow",
271
+ constant: "PROW",
272
+ env: "PROW_JOB_ID"
273
+ },
274
+ {
275
+ name: "ReleaseHub",
276
+ constant: "RELEASEHUB",
277
+ env: "RELEASE_BUILD_ID"
278
+ },
279
+ {
280
+ name: "Render",
281
+ constant: "RENDER",
282
+ env: "RENDER",
283
+ pr: {
284
+ IS_PULL_REQUEST: "true"
285
+ }
286
+ },
287
+ {
288
+ name: "Sail CI",
289
+ constant: "SAIL",
290
+ env: "SAILCI",
291
+ pr: "SAIL_PULL_REQUEST_NUMBER"
292
+ },
293
+ {
294
+ name: "Screwdriver",
295
+ constant: "SCREWDRIVER",
296
+ env: "SCREWDRIVER",
297
+ pr: {
298
+ env: "SD_PULL_REQUEST",
299
+ ne: "false"
300
+ }
301
+ },
302
+ {
303
+ name: "Semaphore",
304
+ constant: "SEMAPHORE",
305
+ env: "SEMAPHORE",
306
+ pr: "PULL_REQUEST_NUMBER"
307
+ },
308
+ {
309
+ name: "Sourcehut",
310
+ constant: "SOURCEHUT",
311
+ env: {
312
+ CI_NAME: "sourcehut"
313
+ }
314
+ },
315
+ {
316
+ name: "Strider CD",
317
+ constant: "STRIDER",
318
+ env: "STRIDER"
319
+ },
320
+ {
321
+ name: "TaskCluster",
322
+ constant: "TASKCLUSTER",
323
+ env: [
324
+ "TASK_ID",
325
+ "RUN_ID"
326
+ ]
327
+ },
328
+ {
329
+ name: "TeamCity",
330
+ constant: "TEAMCITY",
331
+ env: "TEAMCITY_VERSION"
332
+ },
333
+ {
334
+ name: "Travis CI",
335
+ constant: "TRAVIS",
336
+ env: "TRAVIS",
337
+ pr: {
338
+ env: "TRAVIS_PULL_REQUEST",
339
+ ne: "false"
340
+ }
341
+ },
342
+ {
343
+ name: "Vela",
344
+ constant: "VELA",
345
+ env: "VELA",
346
+ pr: {
347
+ VELA_PULL_REQUEST: "1"
348
+ }
349
+ },
350
+ {
351
+ name: "Vercel",
352
+ constant: "VERCEL",
353
+ env: {
354
+ any: [
355
+ "NOW_BUILDER",
356
+ "VERCEL"
357
+ ]
358
+ },
359
+ pr: "VERCEL_GIT_PULL_REQUEST_ID"
360
+ },
361
+ {
362
+ name: "Visual Studio App Center",
363
+ constant: "APPCENTER",
364
+ env: "APPCENTER_BUILD_ID"
365
+ },
366
+ {
367
+ name: "Woodpecker",
368
+ constant: "WOODPECKER",
369
+ env: {
370
+ CI: "woodpecker"
371
+ },
372
+ pr: {
373
+ CI_BUILD_EVENT: "pull_request"
374
+ }
375
+ },
376
+ {
377
+ name: "Xcode Cloud",
378
+ constant: "XCODE_CLOUD",
379
+ env: "CI_XCODE_PROJECT",
380
+ pr: "CI_PULL_REQUEST_NUMBER"
381
+ },
382
+ {
383
+ name: "Xcode Server",
384
+ constant: "XCODE_SERVER",
385
+ env: "XCS"
386
+ }
387
+ ];
388
+ }
389
+ });
390
+
391
+ // ../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/index.js
392
+ var require_ci_info = __commonJS({
393
+ "../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/index.js"(exports) {
394
+ var vendors = require_vendors();
395
+ var env = process.env;
396
+ Object.defineProperty(exports, "_vendors", {
397
+ value: vendors.map(function(v) {
398
+ return v.constant;
399
+ })
400
+ });
401
+ exports.name = null;
402
+ exports.isPR = null;
403
+ exports.id = null;
404
+ if (env.CI !== "false") {
405
+ vendors.forEach(function(vendor) {
406
+ const envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env];
407
+ const isCI2 = envs.every(function(obj) {
408
+ return checkEnv(obj);
409
+ });
410
+ exports[vendor.constant] = isCI2;
411
+ if (!isCI2) {
412
+ return;
413
+ }
414
+ exports.name = vendor.name;
415
+ exports.isPR = checkPR(vendor);
416
+ exports.id = vendor.constant;
417
+ });
418
+ }
419
+ exports.isCI = !!(env.CI !== "false" && // Bypass all checks if CI env is explicitly set to 'false'
420
+ (env.BUILD_ID || // Jenkins, Cloudbees
421
+ env.BUILD_NUMBER || // Jenkins, TeamCity
422
+ env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari, Cloudflare Pages/Workers
423
+ env.CI_APP_ID || // Appflow
424
+ env.CI_BUILD_ID || // Appflow
425
+ env.CI_BUILD_NUMBER || // Appflow
426
+ env.CI_NAME || // Codeship and others
427
+ env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
428
+ env.RUN_ID || // TaskCluster, dsari
429
+ exports.name || false));
430
+ function checkEnv(obj) {
431
+ if (typeof obj === "string") return !!env[obj];
432
+ if ("env" in obj) {
433
+ return env[obj.env] && env[obj.env].includes(obj.includes);
434
+ }
435
+ if ("any" in obj) {
436
+ return obj.any.some(function(k) {
437
+ return !!env[k];
438
+ });
439
+ }
440
+ return Object.keys(obj).every(function(k) {
441
+ return env[k] === obj[k];
442
+ });
443
+ }
444
+ __name(checkEnv, "checkEnv");
445
+ function checkPR(vendor) {
446
+ switch (typeof vendor.pr) {
447
+ case "string":
448
+ return !!env[vendor.pr];
449
+ case "object":
450
+ if ("env" in vendor.pr) {
451
+ if ("any" in vendor.pr) {
452
+ return vendor.pr.any.some(function(key) {
453
+ return env[vendor.pr.env] === key;
454
+ });
455
+ } else {
456
+ return vendor.pr.env in env && env[vendor.pr.env] !== vendor.pr.ne;
457
+ }
458
+ } else if ("any" in vendor.pr) {
459
+ return vendor.pr.any.some(function(key) {
460
+ return !!env[key];
461
+ });
462
+ } else {
463
+ return checkEnv(vendor.pr);
464
+ }
465
+ default:
466
+ return null;
467
+ }
468
+ }
469
+ __name(checkPR, "checkPR");
470
+ }
471
+ });
472
+
21
473
  // ../../node_modules/.pnpm/command-exists@1.2.9/node_modules/command-exists/lib/command-exists.js
22
474
  var require_command_exists = __commonJS({
23
475
  "../../node_modules/.pnpm/command-exists@1.2.9/node_modules/command-exists/lib/command-exists.js"(exports, module) {
24
476
  var exec = __require("child_process").exec;
25
477
  var execSync = __require("child_process").execSync;
26
478
  var fs3 = __require("fs");
27
- var path4 = __require("path");
479
+ var path6 = __require("path");
28
480
  var access = fs3.access;
29
481
  var accessSync2 = fs3.accessSync;
30
482
  var constants2 = fs3.constants || fs3;
@@ -128,9 +580,9 @@ var require_command_exists = __commonJS({
128
580
  cleanInput = /* @__PURE__ */ __name(function(s) {
129
581
  var isPathName = /[\\]/.test(s);
130
582
  if (isPathName) {
131
- var dirname2 = '"' + path4.dirname(s) + '"';
132
- var basename2 = '"' + path4.basename(s) + '"';
133
- return dirname2 + ":" + basename2;
583
+ var dirname3 = '"' + path6.dirname(s) + '"';
584
+ var basename2 = '"' + path6.basename(s) + '"';
585
+ return dirname3 + ":" + basename2;
134
586
  }
135
587
  return '"' + s + '"';
136
588
  }, "cleanInput");
@@ -413,7 +865,7 @@ var require_utils = __commonJS({
413
865
  "../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/lib/utils.js"(exports) {
414
866
  var fs3 = __require("fs");
415
867
  var ini = require_ini();
416
- var path4 = __require("path");
868
+ var path6 = __require("path");
417
869
  var stripJsonComments = require_strip_json_comments();
418
870
  var parse = exports.parse = function(content) {
419
871
  if (/^\s*{/.test(content))
@@ -427,7 +879,7 @@ var require_utils = __commonJS({
427
879
  for (var i in args)
428
880
  if ("string" !== typeof args[i])
429
881
  return;
430
- var file2 = path4.join.apply(null, args);
882
+ var file2 = path6.join.apply(null, args);
431
883
  try {
432
884
  return fs3.readFileSync(file2, "utf-8");
433
885
  } catch (err) {
@@ -464,15 +916,15 @@ var require_utils = __commonJS({
464
916
  return obj;
465
917
  };
466
918
  exports.find = function() {
467
- var rel = path4.join.apply(null, [].slice.call(arguments));
919
+ var rel = path6.join.apply(null, [].slice.call(arguments));
468
920
  function find2(start, rel2) {
469
- var file2 = path4.join(start, rel2);
921
+ var file2 = path6.join(start, rel2);
470
922
  try {
471
923
  fs3.statSync(file2);
472
924
  return file2;
473
925
  } catch (err) {
474
- if (path4.dirname(start) !== start)
475
- return find2(path4.dirname(start), rel2);
926
+ if (path6.dirname(start) !== start)
927
+ return find2(path6.dirname(start), rel2);
476
928
  }
477
929
  }
478
930
  __name(find2, "find");
@@ -773,7 +1225,7 @@ var require_minimist = __commonJS({
773
1225
  var require_rc = __commonJS({
774
1226
  "../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/index.js"(exports, module) {
775
1227
  var cc = require_utils();
776
- var join2 = __require("path").join;
1228
+ var join3 = __require("path").join;
777
1229
  var deepExtend = require_deep_extend();
778
1230
  var etc = "/etc";
779
1231
  var win = process.platform === "win32";
@@ -799,15 +1251,15 @@ var require_rc = __commonJS({
799
1251
  __name(addConfigFile, "addConfigFile");
800
1252
  if (!win)
801
1253
  [
802
- join2(etc, name, "config"),
803
- join2(etc, name + "rc")
1254
+ join3(etc, name, "config"),
1255
+ join3(etc, name + "rc")
804
1256
  ].forEach(addConfigFile);
805
1257
  if (home)
806
1258
  [
807
- join2(home, ".config", name, "config"),
808
- join2(home, ".config", name),
809
- join2(home, "." + name, "config"),
810
- join2(home, "." + name + "rc")
1259
+ join3(home, ".config", name, "config"),
1260
+ join3(home, ".config", name),
1261
+ join3(home, "." + name, "config"),
1262
+ join3(home, "." + name + "rc")
811
1263
  ].forEach(addConfigFile);
812
1264
  addConfigFile(cc.find("." + name + "rc"));
813
1265
  if (env.config) addConfigFile(env.config);
@@ -962,8 +1414,8 @@ var require_registry_auth_token = __commonJS({
962
1414
  return void 0;
963
1415
  }
964
1416
  __name(getLegacyAuthInfo, "getLegacyAuthInfo");
965
- function normalizePath(path4) {
966
- return path4[path4.length - 1] === "/" ? path4 : path4 + "/";
1417
+ function normalizePath(path6) {
1418
+ return path6[path6.length - 1] === "/" ? path6 : path6 + "/";
967
1419
  }
968
1420
  __name(normalizePath, "normalizePath");
969
1421
  function getAuthInfoForUrl(regUrl, npmrc) {
@@ -1013,7 +1465,7 @@ var require_registry_auth_token = __commonJS({
1013
1465
  var require_update_check = __commonJS({
1014
1466
  "../../node_modules/.pnpm/update-check@1.5.4/node_modules/update-check/index.js"(exports, module) {
1015
1467
  var { URL: URL2 } = __require("url");
1016
- var { join: join2 } = __require("path");
1468
+ var { join: join3 } = __require("path");
1017
1469
  var fs3 = __require("fs");
1018
1470
  var { promisify } = __require("util");
1019
1471
  var { tmpdir } = __require("os");
@@ -1025,7 +1477,7 @@ var require_update_check = __commonJS({
1025
1477
  var encode = /* @__PURE__ */ __name((value) => encodeURIComponent(value).replace(/^%40/, "@"), "encode");
1026
1478
  var getFile = /* @__PURE__ */ __name(async (details, distTag) => {
1027
1479
  const rootDir = tmpdir();
1028
- const subDir = join2(rootDir, "update-check");
1480
+ const subDir = join3(rootDir, "update-check");
1029
1481
  if (!fs3.existsSync(subDir)) {
1030
1482
  await mkdir(subDir);
1031
1483
  }
@@ -1033,7 +1485,7 @@ var require_update_check = __commonJS({
1033
1485
  if (details.scope) {
1034
1486
  name = `${details.scope}-${name}`;
1035
1487
  }
1036
- return join2(subDir, name);
1488
+ return join3(subDir, name);
1037
1489
  }, "getFile");
1038
1490
  var evaluateCache = /* @__PURE__ */ __name(async (file, time, interval) => {
1039
1491
  if (fs3.existsSync(file)) {
@@ -1187,6 +1639,7 @@ var defaultWranglerConfig = {
1187
1639
  /* TOP-LEVEL ONLY FIELDS */
1188
1640
  pages_build_output_dir: void 0,
1189
1641
  send_metrics: void 0,
1642
+ dependencies_instrumentation: void 0,
1190
1643
  dev: {
1191
1644
  ip: process.platform === "win32" ? "127.0.0.1" : "localhost",
1192
1645
  port: void 0,
@@ -1244,7 +1697,6 @@ var defaultWranglerConfig = {
1244
1697
  /* Fields supported by Workers only */
1245
1698
  /*====================================================*/
1246
1699
  /* TOP-LEVEL ONLY FIELDS */
1247
- legacy_env: true,
1248
1700
  site: void 0,
1249
1701
  wasm_modules: void 0,
1250
1702
  text_blobs: void 0,
@@ -1301,7 +1753,7 @@ var defaultWranglerConfig = {
1301
1753
  vpc_networks: []
1302
1754
  };
1303
1755
  var experimental_patchConfig = /* @__PURE__ */ __name((configPath, patch, isArrayInsertion = true) => {
1304
- let configString = readFileSync$1(configPath);
1756
+ let configString = readFileSync(configPath);
1305
1757
  if (configPath.endsWith("toml")) {
1306
1758
  if (configString.includes("#")) {
1307
1759
  throw new PatchConfigError(
@@ -1710,8 +2162,8 @@ function getErrorMap() {
1710
2162
  }
1711
2163
  __name(getErrorMap, "getErrorMap");
1712
2164
  var makeIssue = /* @__PURE__ */ __name((params) => {
1713
- const { data, path: path4, errorMaps, issueData } = params;
1714
- const fullPath = [...path4, ...issueData.path || []];
2165
+ const { data, path: path6, errorMaps, issueData } = params;
2166
+ const fullPath = [...path6, ...issueData.path || []];
1715
2167
  const fullIssue = {
1716
2168
  ...issueData,
1717
2169
  path: fullPath
@@ -1817,11 +2269,11 @@ var ParseInputLazyPath = class {
1817
2269
  static {
1818
2270
  __name(this, "ParseInputLazyPath");
1819
2271
  }
1820
- constructor(parent, value, path4, key) {
2272
+ constructor(parent, value, path6, key) {
1821
2273
  this._cachedPath = [];
1822
2274
  this.parent = parent;
1823
2275
  this.data = value;
1824
- this._path = path4;
2276
+ this._path = path6;
1825
2277
  this._key = key;
1826
2278
  }
1827
2279
  get path() {
@@ -5226,7 +5678,7 @@ function isValidWorkflowName(name) {
5226
5678
  __name(isValidWorkflowName, "isValidWorkflowName");
5227
5679
  z.object({
5228
5680
  retries: z.object({
5229
- delay: z.number().gte(0).or(z.string()),
5681
+ delay: z.number().gte(0).or(z.string()).or(z.function()),
5230
5682
  limit: z.number().gte(0),
5231
5683
  backoff: z.enum(["constant", "linear", "exponential"]).optional()
5232
5684
  }).strict().optional(),
@@ -5386,7 +5838,7 @@ var getBuildPlatformFromEnv = getEnvironmentVariableFactory({
5386
5838
  var getRegistryPath = getEnvironmentVariableFactory({
5387
5839
  variableName: "WRANGLER_REGISTRY_PATH",
5388
5840
  defaultValue() {
5389
- return path2.join(getGlobalConfigPath(), "registry");
5841
+ return path2__default.join(getGlobalConfigPath(), "registry");
5390
5842
  }
5391
5843
  });
5392
5844
  var getD1ExtraLocationChoices = getEnvironmentVariableFactory({
@@ -5560,35 +6012,7 @@ function inheritable(diagnostics, topLevelEnv, rawEnv, field, validate, defaultV
5560
6012
  );
5561
6013
  }
5562
6014
  __name(inheritable, "inheritable");
5563
- function inheritableInWranglerEnvironments(diagnostics, useServiceEnvironments, topLevelEnv, rawEnv, field, validate, transformFn = (v) => v, defaultValue) {
5564
- const usingServiceEnvironments = useServiceEnvironments && topLevelEnv !== void 0;
5565
- return usingServiceEnvironments ? notAllowedInNamedServiceEnvironment(
5566
- diagnostics,
5567
- topLevelEnv,
5568
- rawEnv,
5569
- field
5570
- ) : inheritable(
5571
- diagnostics,
5572
- topLevelEnv,
5573
- rawEnv,
5574
- field,
5575
- validate,
5576
- defaultValue,
5577
- transformFn
5578
- );
5579
- }
5580
- __name(inheritableInWranglerEnvironments, "inheritableInWranglerEnvironments");
5581
6015
  var appendEnvName = /* @__PURE__ */ __name((envName) => (fieldValue) => fieldValue ? `${fieldValue}-${envName}` : void 0, "appendEnvName");
5582
- function notAllowedInNamedServiceEnvironment(diagnostics, topLevelEnv, rawEnv, field) {
5583
- if (field in rawEnv) {
5584
- diagnostics.errors.push(
5585
- `The "${field}" field is not allowed in named service environments.
5586
- Please remove the field from this environment.`
5587
- );
5588
- }
5589
- return topLevelEnv[field];
5590
- }
5591
- __name(notAllowedInNamedServiceEnvironment, "notAllowedInNamedServiceEnvironment");
5592
6016
  function notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, field, validate, defaultValue) {
5593
6017
  if (rawEnv[field] !== void 0) {
5594
6018
  validate(diagnostics, field, rawEnv[field], topLevelEnv);
@@ -5604,9 +6028,9 @@ Please add "${field}" to "env.${envName}".`
5604
6028
  return rawEnv[field] ?? defaultValue;
5605
6029
  }
5606
6030
  __name(notInheritable, "notInheritable");
5607
- function unwindPropertyPath(root, path4) {
6031
+ function unwindPropertyPath(root, path6) {
5608
6032
  let container = root;
5609
- const parts = path4.split(".");
6033
+ const parts = path6.split(".");
5610
6034
  for (let i = 0; i < parts.length - 1; i++) {
5611
6035
  if (!hasProperty(container, parts[i])) {
5612
6036
  return;
@@ -5985,15 +6409,18 @@ function isPagesConfig(rawConfig) {
5985
6409
  __name(isPagesConfig, "isPagesConfig");
5986
6410
  function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args, preserveOriginalMain = false) {
5987
6411
  const diagnostics = new Diagnostics(
5988
- `Processing ${configPath ? path2.relative(process.cwd(), configPath) : "wrangler"} configuration:`
5989
- );
5990
- validateOptionalProperty(
5991
- diagnostics,
5992
- "",
5993
- "legacy_env",
5994
- rawConfig.legacy_env,
5995
- "boolean"
6412
+ `Processing ${configPath ? path2__default.relative(process.cwd(), configPath) : "wrangler"} configuration:`
5996
6413
  );
6414
+ if ("legacy_env" in rawConfig) {
6415
+ diagnostics.errors.push(
6416
+ dedent`
6417
+ The "legacy_env" field is no longer supported, so please remove it from your configuration file.
6418
+ Service environments have been removed, and each environment is now deployed as its own Worker named "<name>-<environment>". This matches the behaviour of "legacy_env = true", which was the default, so removing the field will not change how your Worker is deployed.
6419
+ Refer to https://developers.cloudflare.com/workers/wrangler/environments/ for more information.
6420
+ `
6421
+ );
6422
+ delete rawConfig.legacy_env;
6423
+ }
5997
6424
  validateOptionalProperty(
5998
6425
  diagnostics,
5999
6426
  "",
@@ -6001,6 +6428,31 @@ function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args,
6001
6428
  rawConfig.send_metrics,
6002
6429
  "boolean"
6003
6430
  );
6431
+ if (validateOptionalProperty(
6432
+ diagnostics,
6433
+ "",
6434
+ "dependencies_instrumentation",
6435
+ rawConfig.dependencies_instrumentation,
6436
+ "object"
6437
+ )) {
6438
+ if (typeof rawConfig.dependencies_instrumentation === "object") {
6439
+ validateOptionalProperty(
6440
+ diagnostics,
6441
+ "dependencies_instrumentation",
6442
+ "enabled",
6443
+ rawConfig.dependencies_instrumentation.enabled,
6444
+ "boolean"
6445
+ );
6446
+ validateAdditionalProperties(
6447
+ diagnostics,
6448
+ "dependencies_instrumentation",
6449
+ Object.keys(
6450
+ rawConfig.dependencies_instrumentation
6451
+ ),
6452
+ ["enabled"]
6453
+ );
6454
+ }
6455
+ }
6004
6456
  validateOptionalProperty(
6005
6457
  diagnostics,
6006
6458
  "",
@@ -6022,12 +6474,6 @@ function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args,
6022
6474
  rawConfig.$schema,
6023
6475
  "string"
6024
6476
  );
6025
- const useServiceEnvironments = !(args["legacy-env"] ?? rawConfig.legacy_env ?? true);
6026
- if (useServiceEnvironments) {
6027
- diagnostics.warnings.push(
6028
- "Service environments are deprecated, and will be removed in the future. DO NOT USE IN PRODUCTION."
6029
- );
6030
- }
6031
6477
  const isDispatchNamespace = typeof args["dispatch-namespace"] === "string" && args["dispatch-namespace"].trim() !== "";
6032
6478
  const topLevelEnv = normalizeAndValidateEnvironment(
6033
6479
  diagnostics,
@@ -6081,7 +6527,6 @@ function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args,
6081
6527
  preserveOriginalMain,
6082
6528
  envName,
6083
6529
  topLevelEnv,
6084
- useServiceEnvironments,
6085
6530
  rawConfig
6086
6531
  );
6087
6532
  diagnostics.addChild(envDiagnostics);
@@ -6095,7 +6540,6 @@ function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args,
6095
6540
  preserveOriginalMain,
6096
6541
  envName,
6097
6542
  topLevelEnv,
6098
- useServiceEnvironments,
6099
6543
  rawConfig
6100
6544
  );
6101
6545
  const envNames = rawConfig.env ? `The available configured environment names are: ${JSON.stringify(
@@ -6126,9 +6570,8 @@ Consider adding an environment configuration section to the ${configFileName(con
6126
6570
  configPath,
6127
6571
  rawConfig.pages_build_output_dir
6128
6572
  ),
6129
- /** Legacy_env is wrangler environments, as opposed to service environments. Wrangler environments is not legacy. */
6130
- legacy_env: !useServiceEnvironments,
6131
6573
  send_metrics: rawConfig.send_metrics,
6574
+ dependencies_instrumentation: rawConfig.dependencies_instrumentation,
6132
6575
  keep_vars: rawConfig.keep_vars,
6133
6576
  ...activeEnv,
6134
6577
  dev: normalizeAndValidateDev(diagnostics, rawConfig.dev ?? {}, args),
@@ -6210,13 +6653,13 @@ function normalizeAndValidateBuild(diagnostics, rawEnv, rawBuild, configPath) {
6210
6653
  // be configured in the Wrangler configuration file, but who knows, that may
6211
6654
  // change in the future, so we do a check anyway
6212
6655
  command && configPath ? Array.isArray(watch_dir) ? watch_dir.map(
6213
- (dir) => path2.relative(
6656
+ (dir2) => path2__default.relative(
6214
6657
  process.cwd(),
6215
- path2.join(path2.dirname(configPath), `${dir}`)
6658
+ path2__default.join(path2__default.dirname(configPath), `${dir2}`)
6216
6659
  )
6217
- ) : path2.relative(
6660
+ ) : path2__default.relative(
6218
6661
  process.cwd(),
6219
- path2.join(path2.dirname(configPath), `${watch_dir}`)
6662
+ path2__default.join(path2__default.dirname(configPath), `${watch_dir}`)
6220
6663
  ) : watch_dir
6221
6664
  ),
6222
6665
  cwd
@@ -6224,11 +6667,11 @@ function normalizeAndValidateBuild(diagnostics, rawEnv, rawBuild, configPath) {
6224
6667
  }
6225
6668
  __name(normalizeAndValidateBuild, "normalizeAndValidateBuild");
6226
6669
  function normalizeAndValidateMainField(configPath, rawMain) {
6227
- const configDir = path2.dirname(configPath ?? "wrangler.toml");
6670
+ const configDir = path2__default.dirname(configPath ?? "wrangler.toml");
6228
6671
  if (rawMain !== void 0) {
6229
6672
  if (typeof rawMain === "string") {
6230
- const directory = path2.resolve(configDir);
6231
- return path2.resolve(directory, rawMain);
6673
+ const directory = path2__default.resolve(configDir);
6674
+ return path2__default.resolve(directory, rawMain);
6232
6675
  } else {
6233
6676
  return rawMain;
6234
6677
  }
@@ -6238,11 +6681,11 @@ function normalizeAndValidateMainField(configPath, rawMain) {
6238
6681
  }
6239
6682
  __name(normalizeAndValidateMainField, "normalizeAndValidateMainField");
6240
6683
  function normalizeAndValidateBaseDirField(configPath, rawDir) {
6241
- const configDir = path2.dirname(configPath ?? "wrangler.toml");
6684
+ const configDir = path2__default.dirname(configPath ?? "wrangler.toml");
6242
6685
  if (rawDir !== void 0) {
6243
6686
  if (typeof rawDir === "string") {
6244
- const directory = path2.resolve(configDir);
6245
- return path2.resolve(directory, rawDir);
6687
+ const directory = path2__default.resolve(configDir);
6688
+ return path2__default.resolve(directory, rawDir);
6246
6689
  } else {
6247
6690
  return rawDir;
6248
6691
  }
@@ -6252,11 +6695,11 @@ function normalizeAndValidateBaseDirField(configPath, rawDir) {
6252
6695
  }
6253
6696
  __name(normalizeAndValidateBaseDirField, "normalizeAndValidateBaseDirField");
6254
6697
  function normalizeAndValidatePagesBuildOutputDir(configPath, rawPagesDir) {
6255
- const configDir = path2.dirname(configPath ?? "wrangler.toml");
6698
+ const configDir = path2__default.dirname(configPath ?? "wrangler.toml");
6256
6699
  if (rawPagesDir !== void 0) {
6257
6700
  if (typeof rawPagesDir === "string") {
6258
- const directory = path2.resolve(configDir);
6259
- return path2.resolve(directory, rawPagesDir);
6701
+ const directory = path2__default.resolve(configDir);
6702
+ return path2__default.resolve(directory, rawPagesDir);
6260
6703
  } else {
6261
6704
  return rawPagesDir;
6262
6705
  }
@@ -6411,9 +6854,9 @@ function normalizeAndValidateSite(diagnostics, configPath, rawConfig, mainEntryP
6411
6854
  `site.entry-point`,
6412
6855
  `Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
6413
6856
  \`\`\`
6414
- main = "${path2.join(
6857
+ main = "${path2__default.join(
6415
6858
  String(legacySiteEntryPoint) || "workers-site",
6416
- path2.extname(String(legacySiteEntryPoint) || "workers-site") ? "" : "index.js"
6859
+ path2__default.extname(String(legacySiteEntryPoint) || "workers-site") ? "" : "index.js"
6417
6860
  )}"
6418
6861
  \`\`\``,
6419
6862
  false,
@@ -6438,9 +6881,9 @@ Delete the deprecated \`site.entry-point\` field from your config.`
6438
6881
  );
6439
6882
  }
6440
6883
  if (configPath && siteEntryPoint) {
6441
- siteEntryPoint = path2.relative(
6884
+ siteEntryPoint = path2__default.relative(
6442
6885
  process.cwd(),
6443
- path2.join(path2.dirname(configPath), siteEntryPoint)
6886
+ path2__default.join(path2__default.dirname(configPath), siteEntryPoint)
6444
6887
  );
6445
6888
  }
6446
6889
  return {
@@ -6486,9 +6929,9 @@ function normalizeAndValidateModulePaths(diagnostics, configPath, field, rawMapp
6486
6929
  for (const [name, filePath] of Object.entries(rawMapping)) {
6487
6930
  if (isString(diagnostics, `${field}['${name}']`, filePath, void 0)) {
6488
6931
  if (configPath) {
6489
- mapping[name] = configPath ? path2.relative(
6932
+ mapping[name] = configPath ? path2__default.relative(
6490
6933
  process.cwd(),
6491
- path2.join(path2.dirname(configPath), filePath)
6934
+ path2__default.join(path2__default.dirname(configPath), filePath)
6492
6935
  ) : filePath;
6493
6936
  }
6494
6937
  }
@@ -6818,7 +7261,7 @@ var validateStreamingTailConsumers = /* @__PURE__ */ __name((diagnostics, field,
6818
7261
  }
6819
7262
  return isValid2;
6820
7263
  }, "validateStreamingTailConsumers");
6821
- function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDispatchNamespace, preserveOriginalMain, envName = "top level", topLevelEnv, useServiceEnvironments, rawConfig) {
7264
+ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDispatchNamespace, preserveOriginalMain, envName = "top level", topLevelEnv, rawConfig) {
6822
7265
  deprecated(
6823
7266
  diagnostics,
6824
7267
  rawEnv,
@@ -6833,14 +7276,12 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
6833
7276
  experimental(diagnostics, rawEnv, "unsafe");
6834
7277
  }
6835
7278
  const route = normalizeAndValidateRoute(diagnostics, topLevelEnv, rawEnv);
6836
- const account_id = inheritableInWranglerEnvironments(
7279
+ const account_id = inheritable(
6837
7280
  diagnostics,
6838
- useServiceEnvironments,
6839
7281
  topLevelEnv,
6840
7282
  mutateEmptyStringAccountIDValue(diagnostics, rawEnv),
6841
7283
  "account_id",
6842
7284
  isString,
6843
- void 0,
6844
7285
  void 0
6845
7286
  );
6846
7287
  const routes = validateRoutes(
@@ -6913,15 +7354,14 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
6913
7354
  configPath
6914
7355
  ),
6915
7356
  rules: validateAndNormalizeRules(diagnostics, topLevelEnv, rawEnv, envName),
6916
- name: inheritableInWranglerEnvironments(
7357
+ name: inheritable(
6917
7358
  diagnostics,
6918
- useServiceEnvironments,
6919
7359
  topLevelEnv,
6920
7360
  rawEnv,
6921
7361
  "name",
6922
7362
  isDispatchNamespace ? isString : isValidName,
6923
- appendEnvName(envName),
6924
- void 0
7363
+ void 0,
7364
+ appendEnvName(envName)
6925
7365
  ),
6926
7366
  main: preserveOriginalMain ? inheritable(
6927
7367
  diagnostics,
@@ -7537,9 +7977,9 @@ function validateAndNormalizeTsconfig(diagnostics, topLevelEnv, rawEnv, configPa
7537
7977
  isString,
7538
7978
  void 0
7539
7979
  );
7540
- return configPath && tsconfig ? path2.relative(
7980
+ return configPath && tsconfig ? path2__default.relative(
7541
7981
  process.cwd(),
7542
- path2.join(path2.dirname(configPath), tsconfig)
7982
+ path2__default.join(path2__default.dirname(configPath), tsconfig)
7543
7983
  ) : tsconfig;
7544
7984
  }
7545
7985
  __name(validateAndNormalizeTsconfig, "validateAndNormalizeTsconfig");
@@ -8413,9 +8853,9 @@ function validateContainerApp(envName, topLevelName, configPath) {
8413
8853
  let resolvedBuildContextPath = void 0;
8414
8854
  try {
8415
8855
  if (isDockerfile(resolvedImage, configPath)) {
8416
- const baseDir = configPath ? path2.dirname(configPath) : process.cwd();
8417
- resolvedImage = path2.resolve(baseDir, resolvedImage);
8418
- resolvedBuildContextPath = containerAppOptional.image_build_context ? path2.resolve(baseDir, containerAppOptional.image_build_context) : path2.dirname(resolvedImage);
8856
+ const baseDir = configPath ? path2__default.dirname(configPath) : process.cwd();
8857
+ resolvedImage = path2__default.resolve(baseDir, resolvedImage);
8858
+ resolvedBuildContextPath = containerAppOptional.image_build_context ? path2__default.resolve(baseDir, containerAppOptional.image_build_context) : path2__default.dirname(resolvedImage);
8419
8859
  }
8420
8860
  } catch (err) {
8421
8861
  if (err instanceof Error && err.message) {
@@ -10912,8 +11352,8 @@ function isRemoteValid(targetObject, fieldPath, diagnostics) {
10912
11352
  }
10913
11353
  __name(isRemoteValid, "isRemoteValid");
10914
11354
  function isDockerfile(imagePath, configPath) {
10915
- const baseDir = configPath ? path2.dirname(configPath) : process.cwd();
10916
- const maybeDockerfile = path2.resolve(baseDir, imagePath);
11355
+ const baseDir = configPath ? path2__default.dirname(configPath) : process.cwd();
11356
+ const maybeDockerfile = path2__default.resolve(baseDir, imagePath);
10917
11357
  if (fs2.existsSync(maybeDockerfile)) {
10918
11358
  if (isDirectory(maybeDockerfile)) {
10919
11359
  throw new UserError(
@@ -11137,6 +11577,192 @@ Pages requires Durable Object bindings to specify the name of the Worker where t
11137
11577
  }
11138
11578
  }
11139
11579
  __name(validateDurableObjectBinding2, "validateDurableObjectBinding");
11580
+ function getPackagePath(packageName, projectPath) {
11581
+ try {
11582
+ return path2__default.dirname(
11583
+ __require.resolve(`${packageName}/package.json`, {
11584
+ paths: [projectPath]
11585
+ })
11586
+ );
11587
+ } catch {
11588
+ }
11589
+ try {
11590
+ return path2__default.dirname(
11591
+ __require.resolve(packageName, {
11592
+ paths: [projectPath]
11593
+ })
11594
+ );
11595
+ } catch {
11596
+ }
11597
+ return void 0;
11598
+ }
11599
+ __name(getPackagePath, "getPackagePath");
11600
+ function isPackageInstalled(packageName, projectPath) {
11601
+ return !!getPackagePath(packageName, projectPath);
11602
+ }
11603
+ __name(isPackageInstalled, "isPackageInstalled");
11604
+ function getInstalledPackageVersion(packageName, projectPath, opts = {}) {
11605
+ try {
11606
+ const packagePath = getPackagePath(packageName, projectPath);
11607
+ if (!packagePath) {
11608
+ return void 0;
11609
+ }
11610
+ const lastDir = opts.stopAtProjectPath === true ? projectPath : void 0;
11611
+ const packageJsonPath = findFileUp("package.json", packagePath, lastDir);
11612
+ if (!packageJsonPath) {
11613
+ return void 0;
11614
+ }
11615
+ const packageJson = parsePackageJSON(
11616
+ readFileSync(packageJsonPath),
11617
+ packageJsonPath
11618
+ );
11619
+ if (packageJson.name !== packageName) {
11620
+ const bundledVersion = packageJson.bundledVersions?.[packageName];
11621
+ if (bundledVersion !== void 0) {
11622
+ return bundledVersion;
11623
+ }
11624
+ }
11625
+ return packageJson.version;
11626
+ } catch {
11627
+ }
11628
+ }
11629
+ __name(getInstalledPackageVersion, "getInstalledPackageVersion");
11630
+ function findFileUp(name, startDir, lastDir) {
11631
+ let dir2 = startDir;
11632
+ const root = path2__default.parse(dir2).root;
11633
+ while (true) {
11634
+ const candidate = path2__default.join(dir2, name);
11635
+ try {
11636
+ if (statSync(candidate).isFile()) {
11637
+ return candidate;
11638
+ }
11639
+ } catch {
11640
+ }
11641
+ if (lastDir !== void 0 && dir2 === lastDir) {
11642
+ break;
11643
+ }
11644
+ const parent = path2__default.dirname(dir2);
11645
+ if (parent === dir2 || dir2 === root) {
11646
+ break;
11647
+ }
11648
+ dir2 = parent;
11649
+ }
11650
+ return void 0;
11651
+ }
11652
+ __name(findFileUp, "findFileUp");
11653
+
11654
+ // src/is-interactive.ts
11655
+ var import_ci_info = __toESM(require_ci_info());
11656
+ function isTtyInteractive() {
11657
+ try {
11658
+ return Boolean(process.stdin.isTTY && process.stdout.isTTY);
11659
+ } catch {
11660
+ return false;
11661
+ }
11662
+ }
11663
+ __name(isTtyInteractive, "isTtyInteractive");
11664
+ function isInteractive() {
11665
+ if (import_ci_info.default.CLOUDFLARE_PAGES || import_ci_info.default.CLOUDFLARE_WORKERS) {
11666
+ return false;
11667
+ }
11668
+ return isTtyInteractive();
11669
+ }
11670
+ __name(isInteractive, "isInteractive");
11671
+ function isNonInteractiveOrCI() {
11672
+ return !isInteractive() || import_ci_info.default.isCI;
11673
+ }
11674
+ __name(isNonInteractiveOrCI, "isNonInteractiveOrCI");
11675
+ function isCI() {
11676
+ return import_ci_info.default.isCI;
11677
+ }
11678
+ __name(isCI, "isCI");
11679
+
11680
+ // src/config-cache.ts
11681
+ var arrayFormatter = new Intl.ListFormat("en-US", {
11682
+ style: "long",
11683
+ type: "conjunction"
11684
+ });
11685
+ function createConfigCache(logger, options) {
11686
+ let cacheMessageShown = false;
11687
+ const namespace = options?.namespace ?? "wrangler";
11688
+ function getCacheFolder() {
11689
+ if (namespace === "wrangler") {
11690
+ const envCacheDir = getWranglerCacheDirFromEnv();
11691
+ if (envCacheDir) {
11692
+ return envCacheDir;
11693
+ }
11694
+ }
11695
+ const closestNodeModulesDirectory = dir("node_modules");
11696
+ const nodeModulesCache = closestNodeModulesDirectory ? path2.join(closestNodeModulesDirectory, ".cache", namespace) : null;
11697
+ const localCache = path2.join(process.cwd(), `.${namespace}`, "cache");
11698
+ if (nodeModulesCache && existsSync(nodeModulesCache)) {
11699
+ return nodeModulesCache;
11700
+ }
11701
+ if (existsSync(localCache)) {
11702
+ return localCache;
11703
+ }
11704
+ if (nodeModulesCache) {
11705
+ return nodeModulesCache;
11706
+ }
11707
+ return localCache;
11708
+ }
11709
+ __name(getCacheFolder, "getCacheFolder");
11710
+ function showCacheMessage(fields, folder) {
11711
+ if (!cacheMessageShown && !isNonInteractiveOrCI()) {
11712
+ if (fields.length > 0) {
11713
+ logger.debug(
11714
+ `Retrieving cached values for ${arrayFormatter.format(
11715
+ fields
11716
+ )} from ${path2.relative(process.cwd(), folder)}`
11717
+ );
11718
+ cacheMessageShown = true;
11719
+ }
11720
+ }
11721
+ }
11722
+ __name(showCacheMessage, "showCacheMessage");
11723
+ function getConfigCache(fileName) {
11724
+ try {
11725
+ const cacheFolder = getCacheFolder();
11726
+ const configCacheLocation = path2.join(cacheFolder, fileName);
11727
+ const configCache = JSON.parse(
11728
+ readFileSync$1(configCacheLocation, "utf-8")
11729
+ );
11730
+ showCacheMessage(Object.keys(configCache), cacheFolder);
11731
+ return configCache;
11732
+ } catch {
11733
+ return {};
11734
+ }
11735
+ }
11736
+ __name(getConfigCache, "getConfigCache");
11737
+ function saveToConfigCache(fileName, newValues) {
11738
+ const cacheFolder = getCacheFolder();
11739
+ if (cacheFolder) {
11740
+ logger.debug(`Saving to cache: ${JSON.stringify(newValues)}`);
11741
+ const configCacheLocation = path2.join(cacheFolder, fileName);
11742
+ const existingValues = getConfigCache(fileName);
11743
+ mkdirSync(path2.dirname(configCacheLocation), { recursive: true });
11744
+ writeFileSync(
11745
+ configCacheLocation,
11746
+ JSON.stringify({ ...existingValues, ...newValues }, null, 2)
11747
+ );
11748
+ }
11749
+ }
11750
+ __name(saveToConfigCache, "saveToConfigCache");
11751
+ function purgeConfigCaches() {
11752
+ const cacheFolder = getCacheFolder();
11753
+ if (cacheFolder) {
11754
+ removeDirSync(cacheFolder);
11755
+ }
11756
+ }
11757
+ __name(purgeConfigCaches, "purgeConfigCaches");
11758
+ return {
11759
+ getCacheFolder,
11760
+ getConfigCache,
11761
+ saveToConfigCache,
11762
+ purgeConfigCaches
11763
+ };
11764
+ }
11765
+ __name(createConfigCache, "createConfigCache");
11140
11766
 
11141
11767
  // ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
11142
11768
  var signals = [];
@@ -11404,7 +12030,7 @@ var {
11404
12030
  // src/wrangler-tmp-dir.ts
11405
12031
  function getWranglerHiddenDirPath(projectRoot) {
11406
12032
  projectRoot ??= process.cwd();
11407
- return path2.join(projectRoot, ".wrangler");
12033
+ return path2__default.join(projectRoot, ".wrangler");
11408
12034
  }
11409
12035
  __name(getWranglerHiddenDirPath, "getWranglerHiddenDirPath");
11410
12036
  var STALE_WRANGLER_TMP_DIR_MS = 24 * 60 * 60 * 1e3;
@@ -11425,7 +12051,7 @@ function sweepStaleWranglerTmpDirs(tmpRoot) {
11425
12051
  if (!entry.isDirectory()) {
11426
12052
  continue;
11427
12053
  }
11428
- const entryPath = path2.join(tmpRoot, entry.name);
12054
+ const entryPath = path2__default.join(tmpRoot, entry.name);
11429
12055
  try {
11430
12056
  if (fs2.statSync(entryPath).mtimeMs < cutoff) {
11431
12057
  removeDirSync(entryPath);
@@ -11436,10 +12062,10 @@ function sweepStaleWranglerTmpDirs(tmpRoot) {
11436
12062
  }
11437
12063
  __name(sweepStaleWranglerTmpDirs, "sweepStaleWranglerTmpDirs");
11438
12064
  function getWranglerTmpDir(projectRoot, prefix, cleanup = true) {
11439
- const tmpRoot = path2.join(getWranglerHiddenDirPath(projectRoot), "tmp");
12065
+ const tmpRoot = path2__default.join(getWranglerHiddenDirPath(projectRoot), "tmp");
11440
12066
  fs2.mkdirSync(tmpRoot, { recursive: true });
11441
12067
  sweepStaleWranglerTmpDirs(tmpRoot);
11442
- const tmpPrefix = path2.join(tmpRoot, `${prefix}-`);
12068
+ const tmpPrefix = path2__default.join(tmpRoot, `${prefix}-`);
11443
12069
  const tmpDir = fs2.realpathSync(fs2.mkdtempSync(tmpPrefix));
11444
12070
  const cleanupDir = /* @__PURE__ */ __name(() => {
11445
12071
  if (cleanup) {
@@ -11747,9 +12373,9 @@ Update: https://developers.cloudflare.com/cloudflare-one/networks/connectors/clo
11747
12373
  }
11748
12374
  __name(warnIfOutdated, "warnIfOutdated");
11749
12375
  function writeFileAtomic(filePath, contents) {
11750
- const dir = dirname(filePath);
12376
+ const dir2 = dirname(filePath);
11751
12377
  const tmpPath = join(
11752
- dir,
12378
+ dir2,
11753
12379
  `.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`
11754
12380
  );
11755
12381
  try {
@@ -11844,7 +12470,7 @@ async function downloadAndExtractTarball(response, expectedChecksum, binPath, ca
11844
12470
  renameSync(extractedPath, binPath);
11845
12471
  }
11846
12472
  if (expectedChecksum) {
11847
- const extractedBinary = readFileSync(binPath);
12473
+ const extractedBinary = readFileSync$1(binPath);
11848
12474
  const actualSha256 = sha256Hex(extractedBinary);
11849
12475
  if (actualSha256 !== expectedChecksum) {
11850
12476
  throw new UserError(
@@ -12623,6 +13249,35 @@ var LOGGER_LEVELS = {
12623
13249
  log: 3,
12624
13250
  debug: 4
12625
13251
  };
13252
+
13253
+ // src/open-in-browser.ts
13254
+ async function openInBrowser(url, logger) {
13255
+ try {
13256
+ const { default: open } = await import('./open-BCHIM4MY.mjs');
13257
+ const childProcess = await open(url);
13258
+ childProcess.on("error", (err) => {
13259
+ handleBrowserOpenError(url, err, logger);
13260
+ });
13261
+ } catch (err) {
13262
+ if (err.code === "ENOENT") {
13263
+ handleBrowserOpenError(url, err, logger);
13264
+ } else {
13265
+ throw err;
13266
+ }
13267
+ }
13268
+ }
13269
+ __name(openInBrowser, "openInBrowser");
13270
+ function handleBrowserOpenError(url, err, logger) {
13271
+ const isEnoent = err.code === "ENOENT";
13272
+ const hint = process.platform === "linux" && isEnoent ? " You may need to install `xdg-utils` (e.g. `apt install xdg-utils`) or set a default browser." : "";
13273
+ logger.warn(
13274
+ `Failed to open a browser automatically.${hint}
13275
+ Please visit the following URL in your browser:
13276
+ ${url}`
13277
+ );
13278
+ logger.debug(err instanceof Error ? err.stack ?? String(err) : String(err));
13279
+ }
13280
+ __name(handleBrowserOpenError, "handleBrowserOpenError");
12626
13281
  var MAX_ATTEMPTS = 3;
12627
13282
  async function retryOnAPIFailure(action, logger, backoff = 0, attempts = MAX_ATTEMPTS, abortSignal) {
12628
13283
  try {
@@ -12772,7 +13427,7 @@ function getWorkerNameFromProject(projectPath) {
12772
13427
  let packageJsonName;
12773
13428
  try {
12774
13429
  const packageJson = parsePackageJSON(
12775
- readFileSync$1(packageJsonPath),
13430
+ readFileSync(packageJsonPath),
12776
13431
  packageJsonPath
12777
13432
  );
12778
13433
  packageJsonName = packageJson.name;
@@ -12818,4 +13473,4 @@ safe-buffer/index.js:
12818
13473
  (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
12819
13474
  */
12820
13475
 
12821
- export { BunPackageManager, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, Diagnostics, LOGGER_LEVELS, NpmPackageManager, PatchConfigError, PnpmPackageManager, YarnPackageManager, addAuthorizationHeader, bucketFormatMessage, checkWorkerNameValidity, defaultWranglerConfig, experimental_patchConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchKVGetValueBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, formatTime, friendlyBindingNames2 as friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getBrowserRenderingHeadfulFromEnv, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getCloudflaredPathFromEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getDurableObjectExports, getEnvironmentVariableFactory, getHostFromRoute, getHostFromUrl, getLocalExplorerEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkerName, getWorkerNameFromProject, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasDurableObjectExports, hasMorePages, hasProperty, isDockerfile, isOptionalProperty, isPagesConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, maybeAddTraceHeader, normalizeAndValidateConfig, performApiFetchBase, renderError, retryOnAPIFailure, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, toValidWorkerName, truncate, validatePagesConfig };
13476
+ export { BunPackageManager, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, Diagnostics, LOGGER_LEVELS, NpmPackageManager, PatchConfigError, PnpmPackageManager, YarnPackageManager, addAuthorizationHeader, bucketFormatMessage, checkWorkerNameValidity, createConfigCache, defaultWranglerConfig, experimental_patchConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchKVGetValueBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, formatTime, friendlyBindingNames2 as friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getBrowserRenderingHeadfulFromEnv, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getCloudflaredPathFromEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getDurableObjectExports, getEnvironmentVariableFactory, getHostFromRoute, getHostFromUrl, getInstalledPackageVersion, getLocalExplorerEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getPackagePath, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkerName, getWorkerNameFromProject, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasDurableObjectExports, hasMorePages, hasProperty, isCI, isDockerfile, isInteractive, isNonInteractiveOrCI, isOptionalProperty, isPackageInstalled, isPagesConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, maybeAddTraceHeader, normalizeAndValidateConfig, openInBrowser, performApiFetchBase, renderError, retryOnAPIFailure, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, toValidWorkerName, truncate, validatePagesConfig };