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