@cloudflare/workers-utils 0.1.2 → 0.3.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
@@ -1,12 +1,520 @@
1
- import { __name, PATH_TO_DEPLOY_CONFIG } from './chunk-DBPNILFW.mjs';
2
- export { ENVIRONMENT_TAG_PREFIX, INHERIT_SYMBOL, PATH_TO_DEPLOY_CONFIG, SERVICE_TAG_PREFIX, assertNever, constructWranglerConfig, formatCompatibilityDate, mapWorkerMetadataBindings } from './chunk-DBPNILFW.mjs';
1
+ import { PATH_TO_DEPLOY_CONFIG } from './chunk-73TUG5Z7.mjs';
2
+ export { ENVIRONMENT_TAG_PREFIX, INHERIT_SYMBOL, PATH_TO_DEPLOY_CONFIG, SERVICE_TAG_PREFIX, assertNever, constructWranglerConfig, formatCompatibilityDate, mapWorkerMetadataBindings } from './chunk-73TUG5Z7.mjs';
3
+ import { __commonJS, __name, __require, __export, __toESM, __reExport } from './chunk-DCOBXSFB.mjs';
3
4
  import fs, { readFileSync as readFileSync$1, existsSync } from 'node:fs';
4
- import path5, { resolve } from 'node:path';
5
+ import path7, { resolve } from 'node:path';
5
6
  import { fileURLToPath } from 'node:url';
6
7
  import process2 from 'node:process';
7
8
  import { statSync, existsSync as existsSync$1, writeFileSync } from 'fs';
8
9
  import assert from 'node:assert';
9
10
  import path4 from 'path';
11
+ import os from 'node:os';
12
+
13
+ // ../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/lib/XDGAppPaths.js
14
+ var require_XDGAppPaths = __commonJS({
15
+ "../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/lib/XDGAppPaths.js"(exports) {
16
+ exports.__esModule = true;
17
+ exports.Adapt = void 0;
18
+ function isBoolean2(t) {
19
+ return typeOf(t) === "boolean";
20
+ }
21
+ __name(isBoolean2, "isBoolean");
22
+ function isObject(t) {
23
+ return typeOf(t) === "object";
24
+ }
25
+ __name(isObject, "isObject");
26
+ function isString2(t) {
27
+ return typeOf(t) === "string";
28
+ }
29
+ __name(isString2, "isString");
30
+ function typeOf(t) {
31
+ return typeof t;
32
+ }
33
+ __name(typeOf, "typeOf");
34
+ function Adapt(adapter_) {
35
+ var meta = adapter_.meta, path8 = adapter_.path, xdg = adapter_.xdg;
36
+ var XDGAppPaths_ = /* @__PURE__ */ function() {
37
+ function XDGAppPaths_2(options_) {
38
+ if (options_ === void 0) {
39
+ options_ = {};
40
+ }
41
+ var _a, _b, _c;
42
+ function XDGAppPaths(options2) {
43
+ if (options2 === void 0) {
44
+ options2 = {};
45
+ }
46
+ return new XDGAppPaths_2(options2);
47
+ }
48
+ __name(XDGAppPaths, "XDGAppPaths");
49
+ var options = isObject(options_) ? options_ : { name: options_ };
50
+ var suffix = (_a = options.suffix) !== null && _a !== void 0 ? _a : "";
51
+ var isolated_ = (_b = options.isolated) !== null && _b !== void 0 ? _b : true;
52
+ var namePriorityList = [
53
+ options.name,
54
+ meta.pkgMainFilename(),
55
+ meta.mainFilename()
56
+ ];
57
+ var nameFallback = "$eval";
58
+ var name = path8.parse(((_c = namePriorityList.find(function(e) {
59
+ return isString2(e);
60
+ })) !== null && _c !== void 0 ? _c : nameFallback) + suffix).name;
61
+ XDGAppPaths.$name = /* @__PURE__ */ __name(function $name() {
62
+ return name;
63
+ }, "$name");
64
+ XDGAppPaths.$isolated = /* @__PURE__ */ __name(function $isolated() {
65
+ return isolated_;
66
+ }, "$isolated");
67
+ function isIsolated(dirOptions) {
68
+ var _a2;
69
+ dirOptions = dirOptions !== null && dirOptions !== void 0 ? dirOptions : { isolated: isolated_ };
70
+ var isolated = isBoolean2(dirOptions) ? dirOptions : (_a2 = dirOptions.isolated) !== null && _a2 !== void 0 ? _a2 : isolated_;
71
+ return isolated;
72
+ }
73
+ __name(isIsolated, "isIsolated");
74
+ function finalPathSegment(dirOptions) {
75
+ return isIsolated(dirOptions) ? name : "";
76
+ }
77
+ __name(finalPathSegment, "finalPathSegment");
78
+ XDGAppPaths.cache = /* @__PURE__ */ __name(function cache(dirOptions) {
79
+ return path8.join(xdg.cache(), finalPathSegment(dirOptions));
80
+ }, "cache");
81
+ XDGAppPaths.config = /* @__PURE__ */ __name(function config(dirOptions) {
82
+ return path8.join(xdg.config(), finalPathSegment(dirOptions));
83
+ }, "config");
84
+ XDGAppPaths.data = /* @__PURE__ */ __name(function data(dirOptions) {
85
+ return path8.join(xdg.data(), finalPathSegment(dirOptions));
86
+ }, "data");
87
+ XDGAppPaths.runtime = /* @__PURE__ */ __name(function runtime(dirOptions) {
88
+ return xdg.runtime() ? path8.join(xdg.runtime(), finalPathSegment(dirOptions)) : void 0;
89
+ }, "runtime");
90
+ XDGAppPaths.state = /* @__PURE__ */ __name(function state(dirOptions) {
91
+ return path8.join(xdg.state(), finalPathSegment(dirOptions));
92
+ }, "state");
93
+ XDGAppPaths.configDirs = /* @__PURE__ */ __name(function configDirs(dirOptions) {
94
+ return xdg.configDirs().map(function(s) {
95
+ return path8.join(s, finalPathSegment(dirOptions));
96
+ });
97
+ }, "configDirs");
98
+ XDGAppPaths.dataDirs = /* @__PURE__ */ __name(function dataDirs(dirOptions) {
99
+ return xdg.dataDirs().map(function(s) {
100
+ return path8.join(s, finalPathSegment(dirOptions));
101
+ });
102
+ }, "dataDirs");
103
+ return XDGAppPaths;
104
+ }
105
+ __name(XDGAppPaths_2, "XDGAppPaths_");
106
+ return XDGAppPaths_2;
107
+ }();
108
+ return { XDGAppPaths: new XDGAppPaths_() };
109
+ }
110
+ __name(Adapt, "Adapt");
111
+ exports.Adapt = Adapt;
112
+ }
113
+ });
114
+
115
+ // ../../node_modules/.pnpm/xdg-portable@10.6.0/node_modules/xdg-portable/dist/cjs/lib/XDG.js
116
+ var require_XDG = __commonJS({
117
+ "../../node_modules/.pnpm/xdg-portable@10.6.0/node_modules/xdg-portable/dist/cjs/lib/XDG.js"(exports) {
118
+ var __spreadArray = exports && exports.__spreadArray || function(to, from) {
119
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
120
+ to[j] = from[i];
121
+ return to;
122
+ };
123
+ exports.__esModule = true;
124
+ exports.Adapt = void 0;
125
+ function Adapt(adapter_) {
126
+ var env = adapter_.env, osPaths = adapter_.osPaths, path8 = adapter_.path;
127
+ var isMacOS = /^darwin$/i.test(adapter_.process.platform);
128
+ var isWinOS = /^win/i.test(adapter_.process.platform);
129
+ function baseDir() {
130
+ return osPaths.home() || osPaths.temp();
131
+ }
132
+ __name(baseDir, "baseDir");
133
+ function valOrPath(val, pathSegments) {
134
+ return val || path8.join.apply(path8, pathSegments);
135
+ }
136
+ __name(valOrPath, "valOrPath");
137
+ var linux = /* @__PURE__ */ __name(function() {
138
+ var cache = /* @__PURE__ */ __name(function() {
139
+ return valOrPath(env.get("XDG_CACHE_HOME"), [baseDir(), ".cache"]);
140
+ }, "cache");
141
+ var config = /* @__PURE__ */ __name(function() {
142
+ return valOrPath(env.get("XDG_CONFIG_HOME"), [baseDir(), ".config"]);
143
+ }, "config");
144
+ var data = /* @__PURE__ */ __name(function() {
145
+ return valOrPath(env.get("XDG_DATA_HOME"), [baseDir(), ".local", "share"]);
146
+ }, "data");
147
+ var runtime = /* @__PURE__ */ __name(function() {
148
+ return env.get("XDG_RUNTIME_DIR") || void 0;
149
+ }, "runtime");
150
+ var state = /* @__PURE__ */ __name(function() {
151
+ return valOrPath(env.get("XDG_STATE_HOME"), [baseDir(), ".local", "state"]);
152
+ }, "state");
153
+ return { cache, config, data, runtime, state };
154
+ }, "linux");
155
+ var macos = /* @__PURE__ */ __name(function() {
156
+ var cache = /* @__PURE__ */ __name(function() {
157
+ return valOrPath(env.get("XDG_CACHE_HOME"), [baseDir(), "Library", "Caches"]);
158
+ }, "cache");
159
+ var config = /* @__PURE__ */ __name(function() {
160
+ return valOrPath(env.get("XDG_CONFIG_HOME"), [baseDir(), "Library", "Preferences"]);
161
+ }, "config");
162
+ var data = /* @__PURE__ */ __name(function() {
163
+ return valOrPath(env.get("XDG_DATA_HOME"), [baseDir(), "Library", "Application Support"]);
164
+ }, "data");
165
+ var runtime = /* @__PURE__ */ __name(function() {
166
+ return env.get("XDG_RUNTIME_DIR") || void 0;
167
+ }, "runtime");
168
+ var state = /* @__PURE__ */ __name(function() {
169
+ return valOrPath(env.get("XDG_STATE_HOME"), [baseDir(), "Library", "State"]);
170
+ }, "state");
171
+ return { cache, config, data, runtime, state };
172
+ }, "macos");
173
+ var windows = /* @__PURE__ */ __name(function() {
174
+ function appData() {
175
+ return valOrPath(env.get("APPDATA"), [baseDir(), "AppData", "Roaming"]);
176
+ }
177
+ __name(appData, "appData");
178
+ function localAppData() {
179
+ return valOrPath(env.get("LOCALAPPDATA"), [baseDir(), "AppData", "Local"]);
180
+ }
181
+ __name(localAppData, "localAppData");
182
+ var cache = /* @__PURE__ */ __name(function() {
183
+ return valOrPath(env.get("XDG_CACHE_HOME"), [localAppData(), "xdg.cache"]);
184
+ }, "cache");
185
+ var config = /* @__PURE__ */ __name(function() {
186
+ return valOrPath(env.get("XDG_CONFIG_HOME"), [appData(), "xdg.config"]);
187
+ }, "config");
188
+ var data = /* @__PURE__ */ __name(function() {
189
+ return valOrPath(env.get("XDG_DATA_HOME"), [appData(), "xdg.data"]);
190
+ }, "data");
191
+ var runtime = /* @__PURE__ */ __name(function() {
192
+ return env.get("XDG_RUNTIME_DIR") || void 0;
193
+ }, "runtime");
194
+ var state = /* @__PURE__ */ __name(function() {
195
+ return valOrPath(env.get("XDG_STATE_HOME"), [localAppData(), "xdg.state"]);
196
+ }, "state");
197
+ return { cache, config, data, runtime, state };
198
+ }, "windows");
199
+ var XDG_ = /* @__PURE__ */ function() {
200
+ function XDG_2() {
201
+ function XDG() {
202
+ return new XDG_2();
203
+ }
204
+ __name(XDG, "XDG");
205
+ var extension = isMacOS ? macos() : isWinOS ? windows() : linux();
206
+ XDG.cache = extension.cache;
207
+ XDG.config = extension.config;
208
+ XDG.data = extension.data;
209
+ XDG.runtime = extension.runtime;
210
+ XDG.state = extension.state;
211
+ XDG.configDirs = /* @__PURE__ */ __name(function configDirs() {
212
+ var pathList = env.get("XDG_CONFIG_DIRS");
213
+ return __spreadArray([extension.config()], pathList ? pathList.split(path8.delimiter) : []);
214
+ }, "configDirs");
215
+ XDG.dataDirs = /* @__PURE__ */ __name(function dataDirs() {
216
+ var pathList = env.get("XDG_DATA_DIRS");
217
+ return __spreadArray([extension.data()], pathList ? pathList.split(path8.delimiter) : []);
218
+ }, "dataDirs");
219
+ return XDG;
220
+ }
221
+ __name(XDG_2, "XDG_");
222
+ return XDG_2;
223
+ }();
224
+ return { XDG: new XDG_() };
225
+ }
226
+ __name(Adapt, "Adapt");
227
+ exports.Adapt = Adapt;
228
+ }
229
+ });
230
+
231
+ // ../../node_modules/.pnpm/os-paths@7.4.0/node_modules/os-paths/dist/cjs/lib/OSPaths.js
232
+ var require_OSPaths = __commonJS({
233
+ "../../node_modules/.pnpm/os-paths@7.4.0/node_modules/os-paths/dist/cjs/lib/OSPaths.js"(exports) {
234
+ var __spreadArray = exports && exports.__spreadArray || function(to, from) {
235
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
236
+ to[j] = from[i];
237
+ return to;
238
+ };
239
+ exports.__esModule = true;
240
+ exports.Adapt = void 0;
241
+ function isEmpty(s) {
242
+ return !s;
243
+ }
244
+ __name(isEmpty, "isEmpty");
245
+ function Adapt(adapter_) {
246
+ var env = adapter_.env, os2 = adapter_.os, path8 = adapter_.path;
247
+ var isWinOS = /^win/i.test(adapter_.process.platform);
248
+ function normalizePath(path_) {
249
+ return path_ ? adapter_.path.normalize(adapter_.path.join(path_, ".")) : void 0;
250
+ }
251
+ __name(normalizePath, "normalizePath");
252
+ function home() {
253
+ var posix = /* @__PURE__ */ __name(function() {
254
+ return normalizePath((typeof os2.homedir === "function" ? os2.homedir() : void 0) || env.get("HOME"));
255
+ }, "posix");
256
+ var windows = /* @__PURE__ */ __name(function() {
257
+ var priorityList = [
258
+ typeof os2.homedir === "function" ? os2.homedir() : void 0,
259
+ env.get("USERPROFILE"),
260
+ env.get("HOME"),
261
+ env.get("HOMEDRIVE") || env.get("HOMEPATH") ? path8.join(env.get("HOMEDRIVE") || "", env.get("HOMEPATH") || "") : void 0
262
+ ];
263
+ return normalizePath(priorityList.find(function(v) {
264
+ return !isEmpty(v);
265
+ }));
266
+ }, "windows");
267
+ return isWinOS ? windows() : posix();
268
+ }
269
+ __name(home, "home");
270
+ function temp() {
271
+ function joinPathToBase(base, segments) {
272
+ return base ? path8.join.apply(path8, __spreadArray([base], segments)) : void 0;
273
+ }
274
+ __name(joinPathToBase, "joinPathToBase");
275
+ function posix() {
276
+ var fallback = "/tmp";
277
+ var priorityList = [
278
+ typeof os2.tmpdir === "function" ? os2.tmpdir() : void 0,
279
+ env.get("TMPDIR"),
280
+ env.get("TEMP"),
281
+ env.get("TMP")
282
+ ];
283
+ return normalizePath(priorityList.find(function(v) {
284
+ return !isEmpty(v);
285
+ })) || fallback;
286
+ }
287
+ __name(posix, "posix");
288
+ function windows() {
289
+ var fallback = "C:\\Temp";
290
+ var priorityListLazy = [
291
+ typeof os2.tmpdir === "function" ? os2.tmpdir : function() {
292
+ return void 0;
293
+ },
294
+ function() {
295
+ return env.get("TEMP");
296
+ },
297
+ function() {
298
+ return env.get("TMP");
299
+ },
300
+ function() {
301
+ return joinPathToBase(env.get("LOCALAPPDATA"), ["Temp"]);
302
+ },
303
+ function() {
304
+ return joinPathToBase(home(), ["AppData", "Local", "Temp"]);
305
+ },
306
+ function() {
307
+ return joinPathToBase(env.get("ALLUSERSPROFILE"), ["Temp"]);
308
+ },
309
+ function() {
310
+ return joinPathToBase(env.get("SystemRoot"), ["Temp"]);
311
+ },
312
+ function() {
313
+ return joinPathToBase(env.get("windir"), ["Temp"]);
314
+ },
315
+ function() {
316
+ return joinPathToBase(env.get("SystemDrive"), ["\\", "Temp"]);
317
+ }
318
+ ];
319
+ var v = priorityListLazy.find(function(v2) {
320
+ return v2 && !isEmpty(v2());
321
+ });
322
+ return v && normalizePath(v()) || fallback;
323
+ }
324
+ __name(windows, "windows");
325
+ return isWinOS ? windows() : posix();
326
+ }
327
+ __name(temp, "temp");
328
+ var OSPaths_ = /* @__PURE__ */ function() {
329
+ function OSPaths_2() {
330
+ function OSPaths() {
331
+ return new OSPaths_2();
332
+ }
333
+ __name(OSPaths, "OSPaths");
334
+ OSPaths.home = home;
335
+ OSPaths.temp = temp;
336
+ return OSPaths;
337
+ }
338
+ __name(OSPaths_2, "OSPaths_");
339
+ return OSPaths_2;
340
+ }();
341
+ return { OSPaths: new OSPaths_() };
342
+ }
343
+ __name(Adapt, "Adapt");
344
+ exports.Adapt = Adapt;
345
+ }
346
+ });
347
+
348
+ // ../../node_modules/.pnpm/os-paths@7.4.0/node_modules/os-paths/dist/cjs/platform-adapters/node.js
349
+ var require_node = __commonJS({
350
+ "../../node_modules/.pnpm/os-paths@7.4.0/node_modules/os-paths/dist/cjs/platform-adapters/node.js"(exports) {
351
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
352
+ if (k2 === void 0) k2 = k;
353
+ Object.defineProperty(o, k2, { enumerable: true, get: /* @__PURE__ */ __name(function() {
354
+ return m[k];
355
+ }, "get") });
356
+ } : function(o, m, k, k2) {
357
+ if (k2 === void 0) k2 = k;
358
+ o[k2] = m[k];
359
+ });
360
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
361
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
362
+ } : function(o, v) {
363
+ o["default"] = v;
364
+ });
365
+ var __importStar = exports && exports.__importStar || function(mod) {
366
+ if (mod && mod.__esModule) return mod;
367
+ var result = {};
368
+ if (mod != null) {
369
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
370
+ }
371
+ __setModuleDefault(result, mod);
372
+ return result;
373
+ };
374
+ exports.__esModule = true;
375
+ exports.adapter = void 0;
376
+ var os2 = __importStar(__require("os"));
377
+ var path8 = __importStar(__require("path"));
378
+ exports.adapter = {
379
+ atImportPermissions: { env: true },
380
+ env: {
381
+ get: /* @__PURE__ */ __name(function(s) {
382
+ return process.env[s];
383
+ }, "get")
384
+ },
385
+ os: os2,
386
+ path: path8,
387
+ process
388
+ };
389
+ }
390
+ });
391
+
392
+ // ../../node_modules/.pnpm/os-paths@7.4.0/node_modules/os-paths/dist/cjs/mod.cjs.js
393
+ var require_mod_cjs = __commonJS({
394
+ "../../node_modules/.pnpm/os-paths@7.4.0/node_modules/os-paths/dist/cjs/mod.cjs.js"(exports, module) {
395
+ var OSPaths_js_1 = require_OSPaths();
396
+ var node_js_1 = require_node();
397
+ module.exports = OSPaths_js_1.Adapt(node_js_1.adapter).OSPaths;
398
+ }
399
+ });
400
+
401
+ // ../../node_modules/.pnpm/xdg-portable@10.6.0/node_modules/xdg-portable/dist/cjs/platform-adapters/node.js
402
+ var require_node2 = __commonJS({
403
+ "../../node_modules/.pnpm/xdg-portable@10.6.0/node_modules/xdg-portable/dist/cjs/platform-adapters/node.js"(exports) {
404
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
405
+ if (k2 === void 0) k2 = k;
406
+ Object.defineProperty(o, k2, { enumerable: true, get: /* @__PURE__ */ __name(function() {
407
+ return m[k];
408
+ }, "get") });
409
+ } : function(o, m, k, k2) {
410
+ if (k2 === void 0) k2 = k;
411
+ o[k2] = m[k];
412
+ });
413
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
414
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
415
+ } : function(o, v) {
416
+ o["default"] = v;
417
+ });
418
+ var __importStar = exports && exports.__importStar || function(mod) {
419
+ if (mod && mod.__esModule) return mod;
420
+ var result = {};
421
+ if (mod != null) {
422
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
423
+ }
424
+ __setModuleDefault(result, mod);
425
+ return result;
426
+ };
427
+ var __importDefault = exports && exports.__importDefault || function(mod) {
428
+ return mod && mod.__esModule ? mod : { "default": mod };
429
+ };
430
+ exports.__esModule = true;
431
+ exports.adapter = void 0;
432
+ var path8 = __importStar(__require("path"));
433
+ var os_paths_1 = __importDefault(require_mod_cjs());
434
+ exports.adapter = {
435
+ atImportPermissions: { env: true },
436
+ env: {
437
+ get: /* @__PURE__ */ __name(function(s) {
438
+ return process.env[s];
439
+ }, "get")
440
+ },
441
+ osPaths: os_paths_1["default"],
442
+ path: path8,
443
+ process
444
+ };
445
+ }
446
+ });
447
+
448
+ // ../../node_modules/.pnpm/xdg-portable@10.6.0/node_modules/xdg-portable/dist/cjs/mod.cjs.js
449
+ var require_mod_cjs2 = __commonJS({
450
+ "../../node_modules/.pnpm/xdg-portable@10.6.0/node_modules/xdg-portable/dist/cjs/mod.cjs.js"(exports, module) {
451
+ var XDG_js_1 = require_XDG();
452
+ var node_js_1 = require_node2();
453
+ module.exports = XDG_js_1.Adapt(node_js_1.adapter).XDG;
454
+ }
455
+ });
456
+
457
+ // ../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/platform-adapters/node.js
458
+ var require_node3 = __commonJS({
459
+ "../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/platform-adapters/node.js"(exports) {
460
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
461
+ if (k2 === void 0) k2 = k;
462
+ Object.defineProperty(o, k2, { enumerable: true, get: /* @__PURE__ */ __name(function() {
463
+ return m[k];
464
+ }, "get") });
465
+ } : function(o, m, k, k2) {
466
+ if (k2 === void 0) k2 = k;
467
+ o[k2] = m[k];
468
+ });
469
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
470
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
471
+ } : function(o, v) {
472
+ o["default"] = v;
473
+ });
474
+ var __importStar = exports && exports.__importStar || function(mod) {
475
+ if (mod && mod.__esModule) return mod;
476
+ var result = {};
477
+ if (mod != null) {
478
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
479
+ }
480
+ __setModuleDefault(result, mod);
481
+ return result;
482
+ };
483
+ var __importDefault = exports && exports.__importDefault || function(mod) {
484
+ return mod && mod.__esModule ? mod : { "default": mod };
485
+ };
486
+ exports.__esModule = true;
487
+ exports.adapter = void 0;
488
+ var path8 = __importStar(__require("path"));
489
+ var xdg_portable_1 = __importDefault(require_mod_cjs2());
490
+ exports.adapter = {
491
+ atImportPermissions: { env: true, read: true },
492
+ meta: {
493
+ mainFilename: /* @__PURE__ */ __name(function() {
494
+ var requireMain = typeof __require !== "undefined" && __require !== null && __require.main ? __require.main : { filename: void 0 };
495
+ var requireMainFilename = requireMain.filename;
496
+ var filename = (requireMainFilename !== process.execArgv[0] ? requireMainFilename : void 0) || (typeof process._eval === "undefined" ? process.argv[1] : void 0);
497
+ return filename;
498
+ }, "mainFilename"),
499
+ pkgMainFilename: /* @__PURE__ */ __name(function() {
500
+ return process.pkg ? process.execPath : void 0;
501
+ }, "pkgMainFilename")
502
+ },
503
+ path: path8,
504
+ process,
505
+ xdg: xdg_portable_1["default"]
506
+ };
507
+ }
508
+ });
509
+
510
+ // ../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/mod.cjs.js
511
+ var require_mod_cjs3 = __commonJS({
512
+ "../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/mod.cjs.js"(exports, module) {
513
+ var XDGAppPaths_js_1 = require_XDGAppPaths();
514
+ var node_js_1 = require_node3();
515
+ module.exports = XDGAppPaths_js_1.Adapt(node_js_1.adapter).XDGAppPaths;
516
+ }
517
+ });
10
518
 
11
519
  // src/config/config.ts
12
520
  var defaultWranglerConfig = {
@@ -1778,12 +2286,12 @@ function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
1778
2286
  return result;
1779
2287
  }
1780
2288
  __name(parseTree, "parseTree");
1781
- function findNodeAtLocation(root, path6) {
2289
+ function findNodeAtLocation(root, path8) {
1782
2290
  if (!root) {
1783
2291
  return void 0;
1784
2292
  }
1785
2293
  let node = root;
1786
- for (let segment of path6) {
2294
+ for (let segment of path8) {
1787
2295
  if (typeof segment === "string") {
1788
2296
  if (node.type !== "object" || !Array.isArray(node.children)) {
1789
2297
  return void 0;
@@ -2132,14 +2640,14 @@ __name(getNodeType, "getNodeType");
2132
2640
 
2133
2641
  // ../../node_modules/.pnpm/jsonc-parser@3.2.0/node_modules/jsonc-parser/lib/esm/impl/edit.js
2134
2642
  function setProperty(text, originalPath, value, options) {
2135
- const path6 = originalPath.slice();
2643
+ const path8 = originalPath.slice();
2136
2644
  const errors = [];
2137
2645
  const root = parseTree(text, errors);
2138
2646
  let parent = void 0;
2139
2647
  let lastSegment = void 0;
2140
- while (path6.length > 0) {
2141
- lastSegment = path6.pop();
2142
- parent = findNodeAtLocation(root, path6);
2648
+ while (path8.length > 0) {
2649
+ lastSegment = path8.pop();
2650
+ parent = findNodeAtLocation(root, path8);
2143
2651
  if (parent === void 0 && value !== void 0) {
2144
2652
  if (typeof lastSegment === "string") {
2145
2653
  value = { [lastSegment]: value };
@@ -2370,8 +2878,8 @@ function format2(documentText, range, options) {
2370
2878
  return format(documentText, range, options);
2371
2879
  }
2372
2880
  __name(format2, "format");
2373
- function modify(text, path6, value, options) {
2374
- return setProperty(text, path6, value, options);
2881
+ function modify(text, path8, value, options) {
2882
+ return setProperty(text, path8, value, options);
2375
2883
  }
2376
2884
  __name(modify, "modify");
2377
2885
  function applyEdits(text, edits) {
@@ -2675,7 +3183,7 @@ function parseHumanDuration(s) {
2675
3183
  const unitsMap = new Map(Object.entries(units));
2676
3184
  s = s.trim().toLowerCase();
2677
3185
  let base = 1;
2678
- for (const [name, _] of unitsMap) {
3186
+ for (const [name, _2] of unitsMap) {
2679
3187
  if (s.endsWith(name)) {
2680
3188
  s = s.substring(0, s.length - name.length);
2681
3189
  base = unitsMap.get(name) || 1;
@@ -2798,7 +3306,7 @@ function locatePathSync(paths, {
2798
3306
  const statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;
2799
3307
  for (const path_ of paths) {
2800
3308
  try {
2801
- const stat = statFunction(path5.resolve(cwd, path_));
3309
+ const stat = statFunction(path7.resolve(cwd, path_));
2802
3310
  if (matchType(type, stat)) {
2803
3311
  return path_;
2804
3312
  }
@@ -2812,8 +3320,8 @@ __name(locatePathSync, "locatePathSync");
2812
3320
  var toPath2 = /* @__PURE__ */ __name((urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath, "toPath");
2813
3321
  var findUpStop = Symbol("findUpStop");
2814
3322
  function findUpMultipleSync(name, options = {}) {
2815
- let directory = path5.resolve(toPath2(options.cwd) || "");
2816
- const { root } = path5.parse(directory);
3323
+ let directory = path7.resolve(toPath2(options.cwd) || "");
3324
+ const { root } = path7.parse(directory);
2817
3325
  const stopAt = options.stopAt || root;
2818
3326
  const limit = options.limit || Number.POSITIVE_INFINITY;
2819
3327
  const paths = [name].flat();
@@ -2834,12 +3342,12 @@ function findUpMultipleSync(name, options = {}) {
2834
3342
  break;
2835
3343
  }
2836
3344
  if (foundPath) {
2837
- matches.push(path5.resolve(directory, foundPath));
3345
+ matches.push(path7.resolve(directory, foundPath));
2838
3346
  }
2839
3347
  if (directory === stopAt || matches.length >= limit) {
2840
3348
  break;
2841
3349
  }
2842
- directory = path5.dirname(directory);
3350
+ directory = path7.dirname(directory);
2843
3351
  }
2844
3352
  return matches;
2845
3353
  }
@@ -2905,7 +3413,7 @@ function resolveWranglerConfigPath({
2905
3413
  redirected: false
2906
3414
  };
2907
3415
  }
2908
- const leafPath = script !== void 0 ? path5.dirname(script) : process.cwd();
3416
+ const leafPath = script !== void 0 ? path7.dirname(script) : process.cwd();
2909
3417
  return findWranglerConfig(leafPath, options);
2910
3418
  }
2911
3419
  __name(resolveWranglerConfigPath, "resolveWranglerConfigPath");
@@ -2937,16 +3445,16 @@ function findRedirectedWranglerConfig(cwd, userConfigPath) {
2937
3445
  const deployConfigFile = readFileSync(deployConfigPath);
2938
3446
  try {
2939
3447
  const deployConfig = parseJSONC(deployConfigFile, deployConfigPath);
2940
- redirectedConfigPath = deployConfig.configPath && path5.resolve(path5.dirname(deployConfigPath), deployConfig.configPath);
3448
+ redirectedConfigPath = deployConfig.configPath && path7.resolve(path7.dirname(deployConfigPath), deployConfig.configPath);
2941
3449
  } catch (e) {
2942
3450
  throw new UserError(
2943
- `Failed to parse the deploy configuration file at ${path5.relative(".", deployConfigPath)}`,
3451
+ `Failed to parse the deploy configuration file at ${path7.relative(".", deployConfigPath)}`,
2944
3452
  { cause: e }
2945
3453
  );
2946
3454
  }
2947
3455
  if (!redirectedConfigPath) {
2948
3456
  throw new UserError(esm_default`
2949
- A deploy configuration file was found at "${path5.relative(".", deployConfigPath)}".
3457
+ A deploy configuration file was found at "${path7.relative(".", deployConfigPath)}".
2950
3458
  But this is not valid - the required "configPath" property was not found.
2951
3459
  Instead this file contains:
2952
3460
  \`\`\`
@@ -2956,15 +3464,15 @@ function findRedirectedWranglerConfig(cwd, userConfigPath) {
2956
3464
  }
2957
3465
  if (!existsSync(redirectedConfigPath)) {
2958
3466
  throw new UserError(esm_default`
2959
- There is a deploy configuration at "${path5.relative(".", deployConfigPath)}".
2960
- But the redirected configuration path it points to, "${path5.relative(".", redirectedConfigPath)}", does not exist.
3467
+ There is a deploy configuration at "${path7.relative(".", deployConfigPath)}".
3468
+ But the redirected configuration path it points to, "${path7.relative(".", redirectedConfigPath)}", does not exist.
2961
3469
  `);
2962
3470
  }
2963
3471
  if (userConfigPath) {
2964
- if (path5.join(path5.dirname(userConfigPath), PATH_TO_DEPLOY_CONFIG) !== deployConfigPath) {
3472
+ if (path7.join(path7.dirname(userConfigPath), PATH_TO_DEPLOY_CONFIG) !== deployConfigPath) {
2965
3473
  throw new UserError(esm_default`
2966
- Found both a user configuration file at "${path5.relative(".", userConfigPath)}"
2967
- and a deploy configuration file at "${path5.relative(".", deployConfigPath)}".
3474
+ Found both a user configuration file at "${path7.relative(".", userConfigPath)}"
3475
+ and a deploy configuration file at "${path7.relative(".", deployConfigPath)}".
2968
3476
  But these do not share the same base path so it is not clear which should be used.
2969
3477
  `);
2970
3478
  }
@@ -3322,6 +3830,221 @@ function isValidWorkflowName(name) {
3322
3830
  }
3323
3831
  __name(isValidWorkflowName, "isValidWorkflowName");
3324
3832
 
3833
+ // ../../node_modules/.pnpm/xdg-app-paths@8.3.0/node_modules/xdg-app-paths/dist/cjs/esm-wrapper/mod.esm.js
3834
+ var mod_esm_exports = {};
3835
+ __export(mod_esm_exports, {
3836
+ default: () => mod_esm_default
3837
+ });
3838
+ var import_mod_cjs = __toESM(require_mod_cjs3(), 1);
3839
+ __reExport(mod_esm_exports, __toESM(require_mod_cjs3(), 1));
3840
+ var mod_esm_default = import_mod_cjs.default;
3841
+
3842
+ // src/global-wrangler-config-path.ts
3843
+ function isDirectory(configPath) {
3844
+ try {
3845
+ return fs.statSync(configPath).isDirectory();
3846
+ } catch {
3847
+ return false;
3848
+ }
3849
+ }
3850
+ __name(isDirectory, "isDirectory");
3851
+ function getGlobalWranglerConfigPath() {
3852
+ const configDir = mod_esm_default(".wrangler").config();
3853
+ const legacyConfigDir = path7.join(os.homedir(), ".wrangler");
3854
+ if (isDirectory(legacyConfigDir)) {
3855
+ return legacyConfigDir;
3856
+ } else {
3857
+ return configDir;
3858
+ }
3859
+ }
3860
+ __name(getGlobalWranglerConfigPath, "getGlobalWranglerConfigPath");
3861
+
3862
+ // src/environment-variables/factory.ts
3863
+ function getBooleanEnvironmentVariableFactory(options) {
3864
+ return () => {
3865
+ if (!(options.variableName in process.env) || process.env[options.variableName] === void 0) {
3866
+ return typeof options.defaultValue === "function" ? options.defaultValue() : options.defaultValue;
3867
+ }
3868
+ switch (process.env[options.variableName]?.toLowerCase()) {
3869
+ case "true":
3870
+ return true;
3871
+ case "false":
3872
+ return false;
3873
+ default:
3874
+ throw new UserError(
3875
+ `Expected ${options.variableName} to be "true" or "false", but got ${JSON.stringify(
3876
+ process.env[options.variableName]
3877
+ )}`
3878
+ );
3879
+ }
3880
+ };
3881
+ }
3882
+ __name(getBooleanEnvironmentVariableFactory, "getBooleanEnvironmentVariableFactory");
3883
+ function getEnvironmentVariableFactory({
3884
+ variableName,
3885
+ deprecatedName,
3886
+ choices,
3887
+ defaultValue
3888
+ }) {
3889
+ let hasWarned = false;
3890
+ return () => {
3891
+ if (variableName in process.env) {
3892
+ return getProcessEnv(variableName, choices);
3893
+ }
3894
+ if (deprecatedName && deprecatedName in process.env) {
3895
+ if (!hasWarned) {
3896
+ hasWarned = true;
3897
+ console.warn(
3898
+ `Using "${deprecatedName}" environment variable. This is deprecated. Please use "${variableName}", instead.`
3899
+ );
3900
+ }
3901
+ return getProcessEnv(deprecatedName, choices);
3902
+ }
3903
+ return defaultValue?.();
3904
+ };
3905
+ }
3906
+ __name(getEnvironmentVariableFactory, "getEnvironmentVariableFactory");
3907
+ function getProcessEnv(variableName, choices) {
3908
+ assertOneOf(choices, process.env[variableName]);
3909
+ return process.env[variableName];
3910
+ }
3911
+ __name(getProcessEnv, "getProcessEnv");
3912
+ function assertOneOf(choices, value) {
3913
+ if (Array.isArray(choices) && !choices.includes(value)) {
3914
+ throw new UserError(
3915
+ `Expected ${JSON.stringify(value)} to be one of ${JSON.stringify(choices)}`
3916
+ );
3917
+ }
3918
+ }
3919
+ __name(assertOneOf, "assertOneOf");
3920
+
3921
+ // src/environment-variables/misc-variables.ts
3922
+ var getC3CommandFromEnv = getEnvironmentVariableFactory({
3923
+ variableName: "WRANGLER_C3_COMMAND",
3924
+ defaultValue: /* @__PURE__ */ __name(() => "create cloudflare@^2.5.0", "defaultValue")
3925
+ });
3926
+ var getWranglerSendMetricsFromEnv = getBooleanEnvironmentVariableFactory({
3927
+ variableName: "WRANGLER_SEND_METRICS"
3928
+ });
3929
+ var getWranglerSendErrorReportsFromEnv = getBooleanEnvironmentVariableFactory({
3930
+ variableName: "WRANGLER_SEND_ERROR_REPORTS"
3931
+ });
3932
+ var getCloudflareApiEnvironmentFromEnv = getEnvironmentVariableFactory(
3933
+ {
3934
+ variableName: "WRANGLER_API_ENVIRONMENT",
3935
+ defaultValue: /* @__PURE__ */ __name(() => "production", "defaultValue"),
3936
+ choices: ["production", "staging"]
3937
+ }
3938
+ );
3939
+ var COMPLIANCE_REGION_CONFIG_PUBLIC = {
3940
+ compliance_region: "public"
3941
+ };
3942
+ var COMPLIANCE_REGION_CONFIG_UNKNOWN = {
3943
+ compliance_region: void 0
3944
+ };
3945
+ var getCloudflareComplianceRegionFromEnv = getEnvironmentVariableFactory({
3946
+ variableName: "CLOUDFLARE_COMPLIANCE_REGION",
3947
+ choices: ["public", "fedramp_high"]
3948
+ });
3949
+ var getCloudflareComplianceRegion = /* @__PURE__ */ __name((complianceConfig) => {
3950
+ const complianceRegionFromEnv = getCloudflareComplianceRegionFromEnv();
3951
+ if (complianceRegionFromEnv !== void 0 && complianceConfig?.compliance_region !== void 0 && complianceRegionFromEnv !== complianceConfig.compliance_region) {
3952
+ throw new UserError(dedent`
3953
+ The compliance region has been set to different values in two places:
3954
+ - \`CLOUDFLARE_COMPLIANCE_REGION\` environment variable: \`${complianceRegionFromEnv}\`
3955
+ - \`compliance_region\` configuration property: \`${complianceConfig.compliance_region}\`
3956
+ `);
3957
+ }
3958
+ return complianceRegionFromEnv || complianceConfig?.compliance_region || "public";
3959
+ }, "getCloudflareComplianceRegion");
3960
+ var getCloudflareApiBaseUrlFromEnv = getEnvironmentVariableFactory({
3961
+ variableName: "CLOUDFLARE_API_BASE_URL",
3962
+ deprecatedName: "CF_API_BASE_URL"
3963
+ });
3964
+ var getCloudflareApiBaseUrl = /* @__PURE__ */ __name((complianceConfig) => getCloudflareApiBaseUrlFromEnv() ?? `https://api${getComplianceRegionSubdomain(complianceConfig)}${getStagingSubdomain()}.cloudflare.com/client/v4`, "getCloudflareApiBaseUrl");
3965
+ function getComplianceRegionSubdomain(complianceConfig) {
3966
+ return getCloudflareComplianceRegion(complianceConfig) === "fedramp_high" ? ".fed" : "";
3967
+ }
3968
+ __name(getComplianceRegionSubdomain, "getComplianceRegionSubdomain");
3969
+ function getStagingSubdomain() {
3970
+ return getCloudflareApiEnvironmentFromEnv() === "staging" ? ".staging" : "";
3971
+ }
3972
+ __name(getStagingSubdomain, "getStagingSubdomain");
3973
+ var getSanitizeLogs = getBooleanEnvironmentVariableFactory({
3974
+ variableName: "WRANGLER_LOG_SANITIZE",
3975
+ defaultValue: true
3976
+ });
3977
+ var getOutputFileDirectoryFromEnv = getEnvironmentVariableFactory({
3978
+ variableName: "WRANGLER_OUTPUT_FILE_DIRECTORY"
3979
+ });
3980
+ var getOutputFilePathFromEnv = getEnvironmentVariableFactory({
3981
+ variableName: "WRANGLER_OUTPUT_FILE_PATH"
3982
+ });
3983
+ var getCIMatchTag = getEnvironmentVariableFactory({
3984
+ variableName: "WRANGLER_CI_MATCH_TAG"
3985
+ });
3986
+ var getCIOverrideName = getEnvironmentVariableFactory({
3987
+ variableName: "WRANGLER_CI_OVERRIDE_NAME"
3988
+ });
3989
+ var getCIOverrideNetworkModeHost = getEnvironmentVariableFactory({
3990
+ variableName: "WRANGLER_CI_OVERRIDE_NETWORK_MODE_HOST"
3991
+ });
3992
+ var getCIGeneratePreviewAlias = getEnvironmentVariableFactory({
3993
+ variableName: "WRANGLER_CI_GENERATE_PREVIEW_ALIAS",
3994
+ defaultValue: /* @__PURE__ */ __name(() => "false", "defaultValue"),
3995
+ choices: ["true", "false"]
3996
+ });
3997
+ var getWorkersCIBranchName = getEnvironmentVariableFactory({
3998
+ variableName: "WORKERS_CI_BRANCH"
3999
+ });
4000
+ var getBuildConditionsFromEnv = getEnvironmentVariableFactory({
4001
+ variableName: "WRANGLER_BUILD_CONDITIONS"
4002
+ });
4003
+ var getBuildPlatformFromEnv = getEnvironmentVariableFactory({
4004
+ variableName: "WRANGLER_BUILD_PLATFORM"
4005
+ });
4006
+ var getRegistryPath = getEnvironmentVariableFactory({
4007
+ variableName: "WRANGLER_REGISTRY_PATH",
4008
+ defaultValue() {
4009
+ return path7.join(getGlobalWranglerConfigPath(), "registry");
4010
+ }
4011
+ });
4012
+ var getD1ExtraLocationChoices = getEnvironmentVariableFactory({
4013
+ variableName: "WRANGLER_D1_EXTRA_LOCATION_CHOICES"
4014
+ });
4015
+ var getDockerPath = getEnvironmentVariableFactory({
4016
+ variableName: "WRANGLER_DOCKER_BIN",
4017
+ defaultValue() {
4018
+ return "docker";
4019
+ }
4020
+ });
4021
+ var getSubdomainMixedStateCheckDisabled = getBooleanEnvironmentVariableFactory({
4022
+ variableName: "WRANGLER_DISABLE_SUBDOMAIN_MIXED_STATE_CHECK",
4023
+ defaultValue: false
4024
+ });
4025
+ var getCloudflareLoadDevVarsFromDotEnv = getBooleanEnvironmentVariableFactory({
4026
+ variableName: "CLOUDFLARE_LOAD_DEV_VARS_FROM_DOT_ENV",
4027
+ defaultValue: true
4028
+ });
4029
+ var getCloudflareIncludeProcessEnvFromEnv = getBooleanEnvironmentVariableFactory({
4030
+ variableName: "CLOUDFLARE_INCLUDE_PROCESS_ENV",
4031
+ defaultValue: false
4032
+ });
4033
+ var getTraceHeader = getEnvironmentVariableFactory({
4034
+ variableName: "WRANGLER_TRACE_ID"
4035
+ });
4036
+ var getDisableConfigWatching = getBooleanEnvironmentVariableFactory({
4037
+ variableName: "WRANGLER_CI_DISABLE_CONFIG_WATCHING",
4038
+ defaultValue: false
4039
+ });
4040
+ var getWranglerHideBanner = getBooleanEnvironmentVariableFactory({
4041
+ variableName: "WRANGLER_HIDE_BANNER",
4042
+ defaultValue: false
4043
+ });
4044
+ var getCloudflareEnv = getEnvironmentVariableFactory({
4045
+ variableName: "CLOUDFLARE_ENV"
4046
+ });
4047
+
3325
4048
  // src/config/diagnostics.ts
3326
4049
  var Diagnostics = class {
3327
4050
  /**
@@ -3467,9 +4190,9 @@ Please add "${field}" to "env.${envName}".`
3467
4190
  return rawEnv[field] ?? defaultValue;
3468
4191
  }
3469
4192
  __name(notInheritable, "notInheritable");
3470
- function unwindPropertyPath(root, path6) {
4193
+ function unwindPropertyPath(root, path8) {
3471
4194
  let container = root;
3472
- const parts = path6.split(".");
4195
+ const parts = path8.split(".");
3473
4196
  for (let i = 0; i < parts.length - 1; i++) {
3474
4197
  if (!hasProperty(container, parts[i])) {
3475
4198
  return;
@@ -3711,10 +4434,10 @@ var isRecord = /* @__PURE__ */ __name((value) => typeof value === "object" && va
3711
4434
  var validateUniqueNameProperty = /* @__PURE__ */ __name((diagnostics, field, value) => {
3712
4435
  if (Array.isArray(value)) {
3713
4436
  const nameCount = /* @__PURE__ */ new Map();
3714
- Object.entries(value).forEach(([_, entry]) => {
4437
+ Object.entries(value).forEach(([_2, entry]) => {
3715
4438
  nameCount.set(entry.name, (nameCount.get(entry.name) ?? 0) + 1);
3716
4439
  });
3717
- const duplicates = Array.from(nameCount.entries()).filter(([_, count]) => count > 1).map(([name]) => name);
4440
+ const duplicates = Array.from(nameCount.entries()).filter(([_2, count]) => count > 1).map(([name]) => name);
3718
4441
  if (duplicates.length > 0) {
3719
4442
  const list = duplicates.join('", "');
3720
4443
  diagnostics.errors.push(
@@ -3784,7 +4507,7 @@ function isPagesConfig(rawConfig) {
3784
4507
  __name(isPagesConfig, "isPagesConfig");
3785
4508
  function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args, preserveOriginalMain = false) {
3786
4509
  const diagnostics = new Diagnostics(
3787
- `Processing ${configPath ? path5.relative(process.cwd(), configPath) : "wrangler"} configuration:`
4510
+ `Processing ${configPath ? path7.relative(process.cwd(), configPath) : "wrangler"} configuration:`
3788
4511
  );
3789
4512
  validateOptionalProperty(
3790
4513
  diagnostics,
@@ -3853,16 +4576,17 @@ function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args,
3853
4576
  `
3854
4577
  );
3855
4578
  }
3856
- const envName = args.env;
4579
+ const envName = args.env ?? getCloudflareEnv();
3857
4580
  assert(envName === void 0 || typeof envName === "string");
3858
4581
  let activeEnv = topLevelEnv;
3859
4582
  if (envName) {
3860
4583
  if (isRedirectedConfig) {
3861
- if (!isPagesConfig(rawConfig)) {
3862
- diagnostics.errors.push(dedent`
3863
- You have specified the environment "${envName}", but are using a redirected configuration, produced by a build tool such as Vite.
3864
- You need to set the environment in your build tool, rather than via Wrangler.
3865
- For example, if you are using Vite, refer to these docs: https://developers.cloudflare.com/workers/vite-plugin/reference/cloudflare-environments/
4584
+ if (!isPagesConfig(rawConfig) && rawConfig.targetEnvironment && rawConfig.targetEnvironment !== envName) {
4585
+ const via = args.env !== void 0 ? "via the `--env/-e` CLI argument" : "via the CLOUDFLARE_ENV environment variable";
4586
+ throw new Error(dedent`
4587
+ You have specified the environment "${envName}" ${via}.
4588
+ This does not match the target environment "${rawConfig.targetEnvironment}" that was used when building the application.
4589
+ Perhaps you need to re-run the custom build of the project with "${envName}" as the selected environment?
3866
4590
  `);
3867
4591
  }
3868
4592
  } else {
@@ -4007,13 +4731,13 @@ function normalizeAndValidateBuild(diagnostics, rawEnv, rawBuild, configPath) {
4007
4731
  // be configured in the Wrangler configuration file, but who knows, that may
4008
4732
  // change in the future, so we do a check anyway
4009
4733
  command && configPath ? Array.isArray(watch_dir) ? watch_dir.map(
4010
- (dir) => path5.relative(
4734
+ (dir) => path7.relative(
4011
4735
  process.cwd(),
4012
- path5.join(path5.dirname(configPath), `${dir}`)
4736
+ path7.join(path7.dirname(configPath), `${dir}`)
4013
4737
  )
4014
- ) : path5.relative(
4738
+ ) : path7.relative(
4015
4739
  process.cwd(),
4016
- path5.join(path5.dirname(configPath), `${watch_dir}`)
4740
+ path7.join(path7.dirname(configPath), `${watch_dir}`)
4017
4741
  ) : watch_dir
4018
4742
  ),
4019
4743
  cwd
@@ -4021,11 +4745,11 @@ function normalizeAndValidateBuild(diagnostics, rawEnv, rawBuild, configPath) {
4021
4745
  }
4022
4746
  __name(normalizeAndValidateBuild, "normalizeAndValidateBuild");
4023
4747
  function normalizeAndValidateMainField(configPath, rawMain) {
4024
- const configDir = path5.dirname(configPath ?? "wrangler.toml");
4748
+ const configDir = path7.dirname(configPath ?? "wrangler.toml");
4025
4749
  if (rawMain !== void 0) {
4026
4750
  if (typeof rawMain === "string") {
4027
- const directory = path5.resolve(configDir);
4028
- return path5.resolve(directory, rawMain);
4751
+ const directory = path7.resolve(configDir);
4752
+ return path7.resolve(directory, rawMain);
4029
4753
  } else {
4030
4754
  return rawMain;
4031
4755
  }
@@ -4035,11 +4759,11 @@ function normalizeAndValidateMainField(configPath, rawMain) {
4035
4759
  }
4036
4760
  __name(normalizeAndValidateMainField, "normalizeAndValidateMainField");
4037
4761
  function normalizeAndValidateBaseDirField(configPath, rawDir) {
4038
- const configDir = path5.dirname(configPath ?? "wrangler.toml");
4762
+ const configDir = path7.dirname(configPath ?? "wrangler.toml");
4039
4763
  if (rawDir !== void 0) {
4040
4764
  if (typeof rawDir === "string") {
4041
- const directory = path5.resolve(configDir);
4042
- return path5.resolve(directory, rawDir);
4765
+ const directory = path7.resolve(configDir);
4766
+ return path7.resolve(directory, rawDir);
4043
4767
  } else {
4044
4768
  return rawDir;
4045
4769
  }
@@ -4049,11 +4773,11 @@ function normalizeAndValidateBaseDirField(configPath, rawDir) {
4049
4773
  }
4050
4774
  __name(normalizeAndValidateBaseDirField, "normalizeAndValidateBaseDirField");
4051
4775
  function normalizeAndValidatePagesBuildOutputDir(configPath, rawPagesDir) {
4052
- const configDir = path5.dirname(configPath ?? "wrangler.toml");
4776
+ const configDir = path7.dirname(configPath ?? "wrangler.toml");
4053
4777
  if (rawPagesDir !== void 0) {
4054
4778
  if (typeof rawPagesDir === "string") {
4055
- const directory = path5.resolve(configDir);
4056
- return path5.resolve(directory, rawPagesDir);
4779
+ const directory = path7.resolve(configDir);
4780
+ return path7.resolve(directory, rawPagesDir);
4057
4781
  } else {
4058
4782
  return rawPagesDir;
4059
4783
  }
@@ -4185,9 +4909,9 @@ function normalizeAndValidateSite(diagnostics, configPath, rawConfig, mainEntryP
4185
4909
  `site.entry-point`,
4186
4910
  `Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
4187
4911
  \`\`\`
4188
- main = "${path5.join(
4912
+ main = "${path7.join(
4189
4913
  String(rawConfig.site["entry-point"]) || "workers-site",
4190
- path5.extname(String(rawConfig.site["entry-point"]) || "workers-site") ? "" : "index.js"
4914
+ path7.extname(String(rawConfig.site["entry-point"]) || "workers-site") ? "" : "index.js"
4191
4915
  )}"
4192
4916
  \`\`\``,
4193
4917
  false,
@@ -4212,9 +4936,9 @@ Delete the deprecated \`site.entry-point\` field from your config.`
4212
4936
  );
4213
4937
  }
4214
4938
  if (configPath && siteEntryPoint) {
4215
- siteEntryPoint = path5.relative(
4939
+ siteEntryPoint = path7.relative(
4216
4940
  process.cwd(),
4217
- path5.join(path5.dirname(configPath), siteEntryPoint)
4941
+ path7.join(path7.dirname(configPath), siteEntryPoint)
4218
4942
  );
4219
4943
  }
4220
4944
  return {
@@ -4260,9 +4984,9 @@ function normalizeAndValidateModulePaths(diagnostics, configPath, field, rawMapp
4260
4984
  for (const [name, filePath] of Object.entries(rawMapping)) {
4261
4985
  if (isString(diagnostics, `${field}['${name}']`, filePath, void 0)) {
4262
4986
  if (configPath) {
4263
- mapping[name] = configPath ? path5.relative(
4987
+ mapping[name] = configPath ? path7.relative(
4264
4988
  process.cwd(),
4265
- path5.join(path5.dirname(configPath), filePath)
4989
+ path7.join(path7.dirname(configPath), filePath)
4266
4990
  ) : filePath;
4267
4991
  }
4268
4992
  }
@@ -5066,9 +5790,9 @@ function validateAndNormalizeTsconfig(diagnostics, topLevelEnv, rawEnv, configPa
5066
5790
  isString,
5067
5791
  void 0
5068
5792
  );
5069
- return configPath && tsconfig ? path5.relative(
5793
+ return configPath && tsconfig ? path7.relative(
5070
5794
  process.cwd(),
5071
- path5.join(path5.dirname(configPath), tsconfig)
5795
+ path7.join(path7.dirname(configPath), tsconfig)
5072
5796
  ) : tsconfig;
5073
5797
  }
5074
5798
  __name(validateAndNormalizeTsconfig, "validateAndNormalizeTsconfig");
@@ -5827,9 +6551,9 @@ function validateContainerApp(envName, topLevelName, configPath) {
5827
6551
  let resolvedBuildContextPath = void 0;
5828
6552
  try {
5829
6553
  if (isDockerfile(resolvedImage, configPath)) {
5830
- const baseDir = configPath ? path5.dirname(configPath) : process.cwd();
5831
- resolvedImage = path5.resolve(baseDir, resolvedImage);
5832
- resolvedBuildContextPath = containerAppOptional.image_build_context ? path5.resolve(baseDir, containerAppOptional.image_build_context) : path5.dirname(resolvedImage);
6554
+ const baseDir = configPath ? path7.dirname(configPath) : process.cwd();
6555
+ resolvedImage = path7.resolve(baseDir, resolvedImage);
6556
+ resolvedBuildContextPath = containerAppOptional.image_build_context ? path7.resolve(baseDir, containerAppOptional.image_build_context) : path7.dirname(resolvedImage);
5833
6557
  }
5834
6558
  } catch (err) {
5835
6559
  if (err instanceof Error && err.message) {
@@ -5953,6 +6677,15 @@ function validateContainerApp(envName, topLevelName, configPath) {
5953
6677
  `"containers.durable_objects" is deprecated. Use the "class_name" field instead.`
5954
6678
  );
5955
6679
  }
6680
+ if ("unsafe" in containerAppOptional) {
6681
+ if (containerAppOptional.unsafe && typeof containerAppOptional.unsafe !== "object" || Array.isArray(containerAppOptional.unsafe)) {
6682
+ diagnostics.errors.push(
6683
+ `The field "containers.unsafe" should be an object but got ${JSON.stringify(
6684
+ typeof containerAppOptional.unsafe
6685
+ )}.`
6686
+ );
6687
+ }
6688
+ }
5956
6689
  validateAdditionalProperties(
5957
6690
  diagnostics,
5958
6691
  field,
@@ -5973,7 +6706,8 @@ function validateContainerApp(envName, topLevelName, configPath) {
5973
6706
  "rollout_step_percentage",
5974
6707
  "rollout_kind",
5975
6708
  "durable_objects",
5976
- "rollout_active_grace_period"
6709
+ "rollout_active_grace_period",
6710
+ "unsafe"
5977
6711
  ]
5978
6712
  );
5979
6713
  if ("configuration" in containerAppOptional) {
@@ -7690,4 +8424,4 @@ smol-toml/dist/index.js:
7690
8424
  *)
7691
8425
  */
7692
8426
 
7693
- export { APIError, CommandLineArgsError, DeprecationError, FatalError, JsonFriendlyFatalError, MissingConfigError, ParseError, PatchConfigError, UserError, bucketFormatMessage, configFileName, configFormat, createFatalError, defaultWranglerConfig, experimental_patchConfig, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, friendlyBindingNames, hasProperty, indexLocation, isOptionalProperty, isPagesConfig, isRequiredProperty, isValidR2BucketName, normalizeAndValidateConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, readFileSync, readFileSyncToBuffer, resolveWranglerConfigPath, searchLocation, validatePagesConfig };
8427
+ export { APIError, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, CommandLineArgsError, DeprecationError, FatalError, JsonFriendlyFatalError, MissingConfigError, ParseError, PatchConfigError, UserError, bucketFormatMessage, configFileName, configFormat, createFatalError, defaultWranglerConfig, experimental_patchConfig, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, friendlyBindingNames, getBooleanEnvironmentVariableFactory, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getEnvironmentVariableFactory, getGlobalWranglerConfigPath, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkersCIBranchName, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, hasProperty, indexLocation, isOptionalProperty, isPagesConfig, isRequiredProperty, isValidR2BucketName, normalizeAndValidateConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, readFileSync, readFileSyncToBuffer, resolveWranglerConfigPath, searchLocation, validatePagesConfig };