wrangler 4.33.2 → 4.34.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/config-schema.json +2 -2
- package/package.json +11 -11
- package/templates/startDevWorker/InspectorProxyWorker.ts +1 -1
- package/wrangler-dist/InspectorProxyWorker.js +6 -2
- package/wrangler-dist/cli.d.ts +9 -1
- package/wrangler-dist/cli.js +1089 -1011
- package/wrangler-dist/metafile-cjs.json +1 -1
package/wrangler-dist/cli.js
CHANGED
@@ -33841,7 +33841,7 @@ var name, version;
|
|
33841
33841
|
var init_package = __esm({
|
33842
33842
|
"package.json"() {
|
33843
33843
|
name = "wrangler";
|
33844
|
-
version = "4.
|
33844
|
+
version = "4.34.0";
|
33845
33845
|
}
|
33846
33846
|
});
|
33847
33847
|
|
@@ -45300,7 +45300,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
|
|
45300
45300
|
rawEnv,
|
45301
45301
|
"preview_urls",
|
45302
45302
|
isBoolean,
|
45303
|
-
|
45303
|
+
void 0
|
45304
45304
|
);
|
45305
45305
|
const build5 = normalizeAndValidateBuild(
|
45306
45306
|
diagnostics,
|
@@ -45992,6 +45992,7 @@ function validateContainerApp(envName, topLevelName, configPath) {
|
|
45992
45992
|
"instance_type",
|
45993
45993
|
"configuration",
|
45994
45994
|
"constraints",
|
45995
|
+
"affinities",
|
45995
45996
|
"rollout_step_percentage",
|
45996
45997
|
"rollout_kind",
|
45997
45998
|
"durable_objects",
|
@@ -47947,7 +47948,7 @@ var init_config = __esm({
|
|
47947
47948
|
preserve_file_names: void 0,
|
47948
47949
|
base_dir: void 0,
|
47949
47950
|
workers_dev: void 0,
|
47950
|
-
preview_urls:
|
47951
|
+
preview_urls: void 0,
|
47951
47952
|
route: void 0,
|
47952
47953
|
routes: void 0,
|
47953
47954
|
tsconfig: void 0,
|
@@ -53488,7 +53489,7 @@ var init_class_names_sqlite = __esm({
|
|
53488
53489
|
});
|
53489
53490
|
|
53490
53491
|
// ../workers-shared/utils/constants.ts
|
53491
|
-
var PATH_HASH_SIZE, CONTENT_HASH_SIZE, TAIL_SIZE, ENTRY_SIZE,
|
53492
|
+
var PATH_HASH_SIZE, CONTENT_HASH_SIZE, TAIL_SIZE, ENTRY_SIZE, MAX_ASSET_SIZE2, CF_ASSETS_IGNORE_FILENAME, REDIRECTS_FILENAME, HEADERS_FILENAME;
|
53492
53493
|
var init_constants2 = __esm({
|
53493
53494
|
"../workers-shared/utils/constants.ts"() {
|
53494
53495
|
init_import_meta_url();
|
@@ -53496,7 +53497,6 @@ var init_constants2 = __esm({
|
|
53496
53497
|
CONTENT_HASH_SIZE = 16;
|
53497
53498
|
TAIL_SIZE = 8;
|
53498
53499
|
ENTRY_SIZE = PATH_HASH_SIZE + CONTENT_HASH_SIZE + TAIL_SIZE;
|
53499
|
-
MAX_ASSET_COUNT2 = 2e4;
|
53500
53500
|
MAX_ASSET_SIZE2 = 25 * 1024 * 1024;
|
53501
53501
|
CF_ASSETS_IGNORE_FILENAME = ".assetsignore";
|
53502
53502
|
REDIRECTS_FILENAME = "_redirects";
|
@@ -60548,6 +60548,16 @@ var init_BaseController = __esm({
|
|
60548
60548
|
}
|
60549
60549
|
});
|
60550
60550
|
|
60551
|
+
// src/utils/assert-never.ts
|
60552
|
+
function assertNever(_value) {
|
60553
|
+
}
|
60554
|
+
var init_assert_never = __esm({
|
60555
|
+
"src/utils/assert-never.ts"() {
|
60556
|
+
init_import_meta_url();
|
60557
|
+
__name(assertNever, "assertNever");
|
60558
|
+
}
|
60559
|
+
});
|
60560
|
+
|
60551
60561
|
// src/api/startDevWorker/utils.ts
|
60552
60562
|
function createDeferred(previousDeferred) {
|
60553
60563
|
let resolve25, reject;
|
@@ -60564,8 +60574,6 @@ function createDeferred(previousDeferred) {
|
|
60564
60574
|
reject
|
60565
60575
|
};
|
60566
60576
|
}
|
60567
|
-
function assertNever(_value) {
|
60568
|
-
}
|
60569
60577
|
function unwrapHook(hook, ...args) {
|
60570
60578
|
return typeof hook === "function" ? hook(...args) : hook;
|
60571
60579
|
}
|
@@ -60916,8 +60924,8 @@ var init_utils2 = __esm({
|
|
60916
60924
|
init_import_meta_url();
|
60917
60925
|
import_node_assert6 = __toESM(require("assert"));
|
60918
60926
|
import_promises5 = require("fs/promises");
|
60927
|
+
init_assert_never();
|
60919
60928
|
__name(createDeferred, "createDeferred");
|
60920
|
-
__name(assertNever, "assertNever");
|
60921
60929
|
__name(unwrapHook, "unwrapHook");
|
60922
60930
|
__name(getBinaryFileContents, "getBinaryFileContents");
|
60923
60931
|
__name(convertConfigBindingsToStartWorkerBindings, "convertConfigBindingsToStartWorkerBindings");
|
@@ -68974,7 +68982,7 @@ var init_containers2 = __esm({
|
|
68974
68982
|
}
|
68975
68983
|
});
|
68976
68984
|
|
68977
|
-
// src/
|
68985
|
+
// src/utils/diff.ts
|
68978
68986
|
function tokenize(value) {
|
68979
68987
|
const retLines = [];
|
68980
68988
|
const linesAndNewlines = value.split(/(\n|\r\n)/);
|
@@ -68989,7 +68997,7 @@ function tokenize(value) {
|
|
68989
68997
|
}
|
68990
68998
|
var Diff;
|
68991
68999
|
var init_diff = __esm({
|
68992
|
-
"src/
|
69000
|
+
"src/utils/diff.ts"() {
|
68993
69001
|
init_import_meta_url();
|
68994
69002
|
init_cli();
|
68995
69003
|
init_colors();
|
@@ -69414,6 +69422,7 @@ function containerConfigToCreateRequest(accountId, containerApp, imageRef, durab
|
|
69414
69422
|
instances: 0,
|
69415
69423
|
max_instances: containerApp.max_instances,
|
69416
69424
|
constraints: containerApp.constraints,
|
69425
|
+
affinities: containerApp.affinities,
|
69417
69426
|
durable_objects: {
|
69418
69427
|
namespace_id: durableObjectNamespaceId
|
69419
69428
|
},
|
@@ -69573,11 +69582,11 @@ var init_deploy = __esm({
|
|
69573
69582
|
init_colors();
|
69574
69583
|
init_containers_shared();
|
69575
69584
|
init_common();
|
69576
|
-
init_diff();
|
69577
69585
|
init_instance_type();
|
69578
69586
|
init_config2();
|
69579
69587
|
init_errors();
|
69580
69588
|
init_user2();
|
69589
|
+
init_diff();
|
69581
69590
|
init_sortObjectRecursive();
|
69582
69591
|
__name(mergeDeep2, "mergeDeep");
|
69583
69592
|
__name(isObject, "isObject");
|
@@ -69896,6 +69905,16 @@ var init_deploy2 = __esm({
|
|
69896
69905
|
});
|
69897
69906
|
|
69898
69907
|
// src/containers/config.ts
|
69908
|
+
function convertContainerAffinitiesForApi(container) {
|
69909
|
+
if (container.affinities === void 0) {
|
69910
|
+
return void 0;
|
69911
|
+
}
|
69912
|
+
const affinities = {
|
69913
|
+
colocation: container.affinities?.colocation,
|
69914
|
+
hardware_generation: container.affinities?.hardware_generation
|
69915
|
+
};
|
69916
|
+
return affinities;
|
69917
|
+
}
|
69899
69918
|
var import_node_assert12, import_node_path23, getNormalizedContainerOptions;
|
69900
69919
|
var init_config3 = __esm({
|
69901
69920
|
"src/containers/config.ts"() {
|
@@ -69905,6 +69924,7 @@ var init_config3 = __esm({
|
|
69905
69924
|
init_containers_shared();
|
69906
69925
|
init_errors();
|
69907
69926
|
init_user2();
|
69927
|
+
__name(convertContainerAffinitiesForApi, "convertContainerAffinitiesForApi");
|
69908
69928
|
getNormalizedContainerOptions = /* @__PURE__ */ __name(async (config, args) => {
|
69909
69929
|
if (!config.containers || config.containers.length === 0) {
|
69910
69930
|
return [];
|
@@ -69933,7 +69953,7 @@ var init_config3 = __esm({
|
|
69933
69953
|
const shared = {
|
69934
69954
|
name: container.name,
|
69935
69955
|
class_name: container.class_name,
|
69936
|
-
max_instances: container.max_instances ??
|
69956
|
+
max_instances: container.max_instances ?? 1,
|
69937
69957
|
scheduling_policy: container.scheduling_policy ?? "default" /* DEFAULT */,
|
69938
69958
|
constraints: {
|
69939
69959
|
// if the tier is -1, then we allow all tiers
|
@@ -69947,6 +69967,7 @@ var init_config3 = __esm({
|
|
69947
69967
|
(city) => city.toLowerCase()
|
69948
69968
|
)
|
69949
69969
|
},
|
69970
|
+
affinities: convertContainerAffinitiesForApi(container),
|
69950
69971
|
rollout_step_percentage: args?.containersRollout === "immediate" ? 100 : container.rollout_step_percentage ?? rolloutStepPercentageFallback,
|
69951
69972
|
rollout_kind: container.rollout_kind ?? "full_auto",
|
69952
69973
|
rollout_active_grace_period: container.rollout_active_grace_period ?? 0,
|
@@ -72449,863 +72470,6 @@ var init_durable = __esm({
|
|
72449
72470
|
}
|
72450
72471
|
});
|
72451
72472
|
|
72452
|
-
// src/utils/compatibility-date.ts
|
72453
|
-
function getDevCompatibilityDate(config, compatibilityDate = config.compatibility_date) {
|
72454
|
-
const miniflareEntry = require.resolve("miniflare");
|
72455
|
-
const miniflareRequire = import_node_module3.default.createRequire(miniflareEntry);
|
72456
|
-
const miniflareWorkerd = miniflareRequire("workerd");
|
72457
|
-
const workerdDate = miniflareWorkerd.compatibilityDate;
|
72458
|
-
if (config.configPath !== void 0 && compatibilityDate === void 0) {
|
72459
|
-
logger.warn(
|
72460
|
-
`No compatibility_date was specified. Using the installed Workers runtime's latest supported date: ${workerdDate}.
|
72461
|
-
\u276F\u276F Add one to your ${configFileName(config.configPath)} file: compatibility_date = "${workerdDate}", or
|
72462
|
-
\u276F\u276F Pass it in your terminal: wrangler dev [<SCRIPT>] --compatibility-date=${workerdDate}
|
72463
|
-
|
72464
|
-
See https://developers.cloudflare.com/workers/platform/compatibility-dates/ for more information.`
|
72465
|
-
);
|
72466
|
-
}
|
72467
|
-
return compatibilityDate ?? workerdDate;
|
72468
|
-
}
|
72469
|
-
function formatCompatibilityDate(date) {
|
72470
|
-
return date.toISOString().slice(0, 10);
|
72471
|
-
}
|
72472
|
-
var import_node_module3;
|
72473
|
-
var init_compatibility_date = __esm({
|
72474
|
-
"src/utils/compatibility-date.ts"() {
|
72475
|
-
init_import_meta_url();
|
72476
|
-
import_node_module3 = __toESM(require("module"));
|
72477
|
-
init_config2();
|
72478
|
-
init_logger();
|
72479
|
-
__name(getDevCompatibilityDate, "getDevCompatibilityDate");
|
72480
|
-
__name(formatCompatibilityDate, "formatCompatibilityDate");
|
72481
|
-
}
|
72482
|
-
});
|
72483
|
-
|
72484
|
-
// src/utils/create-batches.ts
|
72485
|
-
function* createBatches(array, size) {
|
72486
|
-
for (let i5 = 0; i5 < array.length; i5 += size) {
|
72487
|
-
yield array.slice(i5, i5 + size);
|
72488
|
-
}
|
72489
|
-
}
|
72490
|
-
var init_create_batches = __esm({
|
72491
|
-
"src/utils/create-batches.ts"() {
|
72492
|
-
init_import_meta_url();
|
72493
|
-
__name(createBatches, "createBatches");
|
72494
|
-
}
|
72495
|
-
});
|
72496
|
-
|
72497
|
-
// ../../node_modules/.pnpm/shell-quote@1.8.1/node_modules/shell-quote/quote.js
|
72498
|
-
var require_quote = __commonJS({
|
72499
|
-
"../../node_modules/.pnpm/shell-quote@1.8.1/node_modules/shell-quote/quote.js"(exports2, module3) {
|
72500
|
-
"use strict";
|
72501
|
-
init_import_meta_url();
|
72502
|
-
module3.exports = /* @__PURE__ */ __name(function quote2(xs) {
|
72503
|
-
return xs.map(function(s5) {
|
72504
|
-
if (s5 && typeof s5 === "object") {
|
72505
|
-
return s5.op.replace(/(.)/g, "\\$1");
|
72506
|
-
}
|
72507
|
-
if (/["\s]/.test(s5) && !/'/.test(s5)) {
|
72508
|
-
return "'" + s5.replace(/(['\\])/g, "\\$1") + "'";
|
72509
|
-
}
|
72510
|
-
if (/["'\s]/.test(s5)) {
|
72511
|
-
return '"' + s5.replace(/(["\\$`!])/g, "\\$1") + '"';
|
72512
|
-
}
|
72513
|
-
return String(s5).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g, "$1\\$2");
|
72514
|
-
}).join(" ");
|
72515
|
-
}, "quote");
|
72516
|
-
}
|
72517
|
-
});
|
72518
|
-
|
72519
|
-
// ../../node_modules/.pnpm/shell-quote@1.8.1/node_modules/shell-quote/parse.js
|
72520
|
-
var require_parse4 = __commonJS({
|
72521
|
-
"../../node_modules/.pnpm/shell-quote@1.8.1/node_modules/shell-quote/parse.js"(exports2, module3) {
|
72522
|
-
"use strict";
|
72523
|
-
init_import_meta_url();
|
72524
|
-
var CONTROL = "(?:" + [
|
72525
|
-
"\\|\\|",
|
72526
|
-
"\\&\\&",
|
72527
|
-
";;",
|
72528
|
-
"\\|\\&",
|
72529
|
-
"\\<\\(",
|
72530
|
-
"\\<\\<\\<",
|
72531
|
-
">>",
|
72532
|
-
">\\&",
|
72533
|
-
"<\\&",
|
72534
|
-
"[&;()|<>]"
|
72535
|
-
].join("|") + ")";
|
72536
|
-
var controlRE = new RegExp("^" + CONTROL + "$");
|
72537
|
-
var META = "|&;()<> \\t";
|
72538
|
-
var SINGLE_QUOTE = '"((\\\\"|[^"])*?)"';
|
72539
|
-
var DOUBLE_QUOTE = "'((\\\\'|[^'])*?)'";
|
72540
|
-
var hash = /^#$/;
|
72541
|
-
var SQ = "'";
|
72542
|
-
var DQ = '"';
|
72543
|
-
var DS = "$";
|
72544
|
-
var TOKEN = "";
|
72545
|
-
var mult = 4294967296;
|
72546
|
-
for (i5 = 0; i5 < 4; i5++) {
|
72547
|
-
TOKEN += (mult * Math.random()).toString(16);
|
72548
|
-
}
|
72549
|
-
var i5;
|
72550
|
-
var startsWithToken = new RegExp("^" + TOKEN);
|
72551
|
-
function matchAll(s5, r7) {
|
72552
|
-
var origIndex = r7.lastIndex;
|
72553
|
-
var matches = [];
|
72554
|
-
var matchObj;
|
72555
|
-
while (matchObj = r7.exec(s5)) {
|
72556
|
-
matches.push(matchObj);
|
72557
|
-
if (r7.lastIndex === matchObj.index) {
|
72558
|
-
r7.lastIndex += 1;
|
72559
|
-
}
|
72560
|
-
}
|
72561
|
-
r7.lastIndex = origIndex;
|
72562
|
-
return matches;
|
72563
|
-
}
|
72564
|
-
__name(matchAll, "matchAll");
|
72565
|
-
function getVar(env6, pre, key) {
|
72566
|
-
var r7 = typeof env6 === "function" ? env6(key) : env6[key];
|
72567
|
-
if (typeof r7 === "undefined" && key != "") {
|
72568
|
-
r7 = "";
|
72569
|
-
} else if (typeof r7 === "undefined") {
|
72570
|
-
r7 = "$";
|
72571
|
-
}
|
72572
|
-
if (typeof r7 === "object") {
|
72573
|
-
return pre + TOKEN + JSON.stringify(r7) + TOKEN;
|
72574
|
-
}
|
72575
|
-
return pre + r7;
|
72576
|
-
}
|
72577
|
-
__name(getVar, "getVar");
|
72578
|
-
function parseInternal(string, env6, opts) {
|
72579
|
-
if (!opts) {
|
72580
|
-
opts = {};
|
72581
|
-
}
|
72582
|
-
var BS = opts.escape || "\\";
|
72583
|
-
var BAREWORD = "(\\" + BS + `['"` + META + `]|[^\\s'"` + META + "])+";
|
72584
|
-
var chunker = new RegExp([
|
72585
|
-
"(" + CONTROL + ")",
|
72586
|
-
// control chars
|
72587
|
-
"(" + BAREWORD + "|" + SINGLE_QUOTE + "|" + DOUBLE_QUOTE + ")+"
|
72588
|
-
].join("|"), "g");
|
72589
|
-
var matches = matchAll(string, chunker);
|
72590
|
-
if (matches.length === 0) {
|
72591
|
-
return [];
|
72592
|
-
}
|
72593
|
-
if (!env6) {
|
72594
|
-
env6 = {};
|
72595
|
-
}
|
72596
|
-
var commented = false;
|
72597
|
-
return matches.map(function(match2) {
|
72598
|
-
var s5 = match2[0];
|
72599
|
-
if (!s5 || commented) {
|
72600
|
-
return void 0;
|
72601
|
-
}
|
72602
|
-
if (controlRE.test(s5)) {
|
72603
|
-
return { op: s5 };
|
72604
|
-
}
|
72605
|
-
var quote2 = false;
|
72606
|
-
var esc = false;
|
72607
|
-
var out = "";
|
72608
|
-
var isGlob = false;
|
72609
|
-
var i6;
|
72610
|
-
function parseEnvVar() {
|
72611
|
-
i6 += 1;
|
72612
|
-
var varend;
|
72613
|
-
var varname;
|
72614
|
-
var char = s5.charAt(i6);
|
72615
|
-
if (char === "{") {
|
72616
|
-
i6 += 1;
|
72617
|
-
if (s5.charAt(i6) === "}") {
|
72618
|
-
throw new Error("Bad substitution: " + s5.slice(i6 - 2, i6 + 1));
|
72619
|
-
}
|
72620
|
-
varend = s5.indexOf("}", i6);
|
72621
|
-
if (varend < 0) {
|
72622
|
-
throw new Error("Bad substitution: " + s5.slice(i6));
|
72623
|
-
}
|
72624
|
-
varname = s5.slice(i6, varend);
|
72625
|
-
i6 = varend;
|
72626
|
-
} else if (/[*@#?$!_-]/.test(char)) {
|
72627
|
-
varname = char;
|
72628
|
-
i6 += 1;
|
72629
|
-
} else {
|
72630
|
-
var slicedFromI = s5.slice(i6);
|
72631
|
-
varend = slicedFromI.match(/[^\w\d_]/);
|
72632
|
-
if (!varend) {
|
72633
|
-
varname = slicedFromI;
|
72634
|
-
i6 = s5.length;
|
72635
|
-
} else {
|
72636
|
-
varname = slicedFromI.slice(0, varend.index);
|
72637
|
-
i6 += varend.index - 1;
|
72638
|
-
}
|
72639
|
-
}
|
72640
|
-
return getVar(env6, "", varname);
|
72641
|
-
}
|
72642
|
-
__name(parseEnvVar, "parseEnvVar");
|
72643
|
-
for (i6 = 0; i6 < s5.length; i6++) {
|
72644
|
-
var c6 = s5.charAt(i6);
|
72645
|
-
isGlob = isGlob || !quote2 && (c6 === "*" || c6 === "?");
|
72646
|
-
if (esc) {
|
72647
|
-
out += c6;
|
72648
|
-
esc = false;
|
72649
|
-
} else if (quote2) {
|
72650
|
-
if (c6 === quote2) {
|
72651
|
-
quote2 = false;
|
72652
|
-
} else if (quote2 == SQ) {
|
72653
|
-
out += c6;
|
72654
|
-
} else {
|
72655
|
-
if (c6 === BS) {
|
72656
|
-
i6 += 1;
|
72657
|
-
c6 = s5.charAt(i6);
|
72658
|
-
if (c6 === DQ || c6 === BS || c6 === DS) {
|
72659
|
-
out += c6;
|
72660
|
-
} else {
|
72661
|
-
out += BS + c6;
|
72662
|
-
}
|
72663
|
-
} else if (c6 === DS) {
|
72664
|
-
out += parseEnvVar();
|
72665
|
-
} else {
|
72666
|
-
out += c6;
|
72667
|
-
}
|
72668
|
-
}
|
72669
|
-
} else if (c6 === DQ || c6 === SQ) {
|
72670
|
-
quote2 = c6;
|
72671
|
-
} else if (controlRE.test(c6)) {
|
72672
|
-
return { op: s5 };
|
72673
|
-
} else if (hash.test(c6)) {
|
72674
|
-
commented = true;
|
72675
|
-
var commentObj = { comment: string.slice(match2.index + i6 + 1) };
|
72676
|
-
if (out.length) {
|
72677
|
-
return [out, commentObj];
|
72678
|
-
}
|
72679
|
-
return [commentObj];
|
72680
|
-
} else if (c6 === BS) {
|
72681
|
-
esc = true;
|
72682
|
-
} else if (c6 === DS) {
|
72683
|
-
out += parseEnvVar();
|
72684
|
-
} else {
|
72685
|
-
out += c6;
|
72686
|
-
}
|
72687
|
-
}
|
72688
|
-
if (isGlob) {
|
72689
|
-
return { op: "glob", pattern: out };
|
72690
|
-
}
|
72691
|
-
return out;
|
72692
|
-
}).reduce(function(prev, arg) {
|
72693
|
-
return typeof arg === "undefined" ? prev : prev.concat(arg);
|
72694
|
-
}, []);
|
72695
|
-
}
|
72696
|
-
__name(parseInternal, "parseInternal");
|
72697
|
-
module3.exports = /* @__PURE__ */ __name(function parse7(s5, env6, opts) {
|
72698
|
-
var mapped = parseInternal(s5, env6, opts);
|
72699
|
-
if (typeof env6 !== "function") {
|
72700
|
-
return mapped;
|
72701
|
-
}
|
72702
|
-
return mapped.reduce(function(acc, s6) {
|
72703
|
-
if (typeof s6 === "object") {
|
72704
|
-
return acc.concat(s6);
|
72705
|
-
}
|
72706
|
-
var xs = s6.split(RegExp("(" + TOKEN + ".*?" + TOKEN + ")", "g"));
|
72707
|
-
if (xs.length === 1) {
|
72708
|
-
return acc.concat(xs[0]);
|
72709
|
-
}
|
72710
|
-
return acc.concat(xs.filter(Boolean).map(function(x6) {
|
72711
|
-
if (startsWithToken.test(x6)) {
|
72712
|
-
return JSON.parse(x6.split(TOKEN)[1]);
|
72713
|
-
}
|
72714
|
-
return x6;
|
72715
|
-
}));
|
72716
|
-
}, []);
|
72717
|
-
}, "parse");
|
72718
|
-
}
|
72719
|
-
});
|
72720
|
-
|
72721
|
-
// ../../node_modules/.pnpm/shell-quote@1.8.1/node_modules/shell-quote/index.js
|
72722
|
-
var require_shell_quote = __commonJS({
|
72723
|
-
"../../node_modules/.pnpm/shell-quote@1.8.1/node_modules/shell-quote/index.js"(exports2) {
|
72724
|
-
"use strict";
|
72725
|
-
init_import_meta_url();
|
72726
|
-
exports2.quote = require_quote();
|
72727
|
-
exports2.parse = require_parse4();
|
72728
|
-
}
|
72729
|
-
});
|
72730
|
-
|
72731
|
-
// src/utils/shell-quote.ts
|
72732
|
-
function parse4(cmd, env6) {
|
72733
|
-
if (process.platform === "win32") {
|
72734
|
-
cmd = cmd.replaceAll("\\", "\\\\");
|
72735
|
-
}
|
72736
|
-
const entries = import_shell_quote.default.parse(cmd, env6);
|
72737
|
-
const argv = [];
|
72738
|
-
for (const entry of entries) {
|
72739
|
-
if (typeof entry === "string") {
|
72740
|
-
argv.push(entry);
|
72741
|
-
continue;
|
72742
|
-
}
|
72743
|
-
if ("comment" in entry) {
|
72744
|
-
continue;
|
72745
|
-
}
|
72746
|
-
if (entry.op === "glob") {
|
72747
|
-
argv.push(entry.pattern);
|
72748
|
-
continue;
|
72749
|
-
}
|
72750
|
-
throw new Error(
|
72751
|
-
`Only simple commands are supported, please don't use the "${entry.op}" operator in "${cmd}".`
|
72752
|
-
);
|
72753
|
-
}
|
72754
|
-
return argv;
|
72755
|
-
}
|
72756
|
-
var import_shell_quote, quote;
|
72757
|
-
var init_shell_quote = __esm({
|
72758
|
-
"src/utils/shell-quote.ts"() {
|
72759
|
-
init_import_meta_url();
|
72760
|
-
import_shell_quote = __toESM(require_shell_quote());
|
72761
|
-
quote = /* @__PURE__ */ __name(function(args) {
|
72762
|
-
const stringArgs = args.map((arg) => String(arg));
|
72763
|
-
return import_shell_quote.default.quote(stringArgs);
|
72764
|
-
}, "quote");
|
72765
|
-
__name(parse4, "parse");
|
72766
|
-
}
|
72767
|
-
});
|
72768
|
-
|
72769
|
-
// src/init.ts
|
72770
|
-
function isNpm(packageManager) {
|
72771
|
-
return packageManager.type === "npm";
|
72772
|
-
}
|
72773
|
-
async function downloadWorkerConfig(accountId, workerName, entrypoint, serviceEnvironment) {
|
72774
|
-
const [
|
72775
|
-
bindings,
|
72776
|
-
routes,
|
72777
|
-
customDomains,
|
72778
|
-
workersDev,
|
72779
|
-
serviceEnvMetadata,
|
72780
|
-
cronTriggers
|
72781
|
-
] = await Promise.all([
|
72782
|
-
fetchResult(
|
72783
|
-
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
72784
|
-
`/accounts/${accountId}/workers/services/${workerName}/environments/${serviceEnvironment}/bindings`
|
72785
|
-
),
|
72786
|
-
fetchResult(
|
72787
|
-
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
72788
|
-
`/accounts/${accountId}/workers/services/${workerName}/environments/${serviceEnvironment}/routes?show_zonename=true`
|
72789
|
-
),
|
72790
|
-
fetchResult(
|
72791
|
-
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
72792
|
-
`/accounts/${accountId}/workers/domains/records?page=0&per_page=5&service=${workerName}&environment=${serviceEnvironment}`
|
72793
|
-
),
|
72794
|
-
fetchResult(
|
72795
|
-
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
72796
|
-
`/accounts/${accountId}/workers/services/${workerName}/environments/${serviceEnvironment}/subdomain`
|
72797
|
-
),
|
72798
|
-
fetchResult(
|
72799
|
-
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
72800
|
-
`/accounts/${accountId}/workers/services/${workerName}/environments/${serviceEnvironment}`
|
72801
|
-
),
|
72802
|
-
fetchResult(
|
72803
|
-
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
72804
|
-
`/accounts/${accountId}/workers/scripts/${workerName}/schedules`
|
72805
|
-
)
|
72806
|
-
]).catch((e7) => {
|
72807
|
-
throw new Error(
|
72808
|
-
`Error Occurred ${e7}: Unable to fetch bindings, routes, or services metadata from the dashboard. Please try again later.`
|
72809
|
-
);
|
72810
|
-
});
|
72811
|
-
const mappedBindings = await mapBindings(
|
72812
|
-
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
72813
|
-
accountId,
|
72814
|
-
bindings
|
72815
|
-
);
|
72816
|
-
const durableObjectClassNames = bindings.filter((binding) => binding.type === "durable_object_namespace").map(
|
72817
|
-
(durableObject) => durableObject.class_name
|
72818
|
-
);
|
72819
|
-
const allRoutes = [
|
72820
|
-
...routes.map(
|
72821
|
-
(r7) => ({ pattern: r7.pattern, zone_name: r7.zone_name })
|
72822
|
-
),
|
72823
|
-
...customDomains.map(
|
72824
|
-
(c6) => ({
|
72825
|
-
pattern: c6.hostname,
|
72826
|
-
zone_name: c6.zone_name,
|
72827
|
-
custom_domain: true
|
72828
|
-
})
|
72829
|
-
)
|
72830
|
-
];
|
72831
|
-
return {
|
72832
|
-
name: workerName,
|
72833
|
-
main: entrypoint,
|
72834
|
-
workers_dev: workersDev.enabled,
|
72835
|
-
compatibility_date: serviceEnvMetadata.script.compatibility_date ?? formatCompatibilityDate(/* @__PURE__ */ new Date()),
|
72836
|
-
compatibility_flags: serviceEnvMetadata.script.compatibility_flags,
|
72837
|
-
...allRoutes.length ? { routes: allRoutes } : {},
|
72838
|
-
placement: serviceEnvMetadata.script.placement_mode === "smart" ? { mode: "smart" } : void 0,
|
72839
|
-
limits: serviceEnvMetadata.script.limits,
|
72840
|
-
...durableObjectClassNames.length ? {
|
72841
|
-
migrations: [
|
72842
|
-
{
|
72843
|
-
tag: serviceEnvMetadata.script.migration_tag,
|
72844
|
-
new_classes: durableObjectClassNames
|
72845
|
-
}
|
72846
|
-
]
|
72847
|
-
} : {},
|
72848
|
-
...cronTriggers.schedules.length ? {
|
72849
|
-
triggers: {
|
72850
|
-
crons: cronTriggers.schedules.map((scheduled) => scheduled.cron)
|
72851
|
-
}
|
72852
|
-
} : {},
|
72853
|
-
tail_consumers: serviceEnvMetadata.script.tail_consumers ?? void 0,
|
72854
|
-
observability: serviceEnvMetadata.script.observability,
|
72855
|
-
...mappedBindings
|
72856
|
-
};
|
72857
|
-
}
|
72858
|
-
async function mapBindings(complianceConfig, accountId, bindings) {
|
72859
|
-
const d1BindingsWithInfo = {};
|
72860
|
-
await Promise.all(
|
72861
|
-
bindings.filter((binding) => binding.type === "d1").map(async (binding) => {
|
72862
|
-
const dbInfo = await getDatabaseInfoFromIdOrName(
|
72863
|
-
complianceConfig,
|
72864
|
-
accountId,
|
72865
|
-
binding.id
|
72866
|
-
);
|
72867
|
-
d1BindingsWithInfo[binding.id] = dbInfo;
|
72868
|
-
})
|
72869
|
-
);
|
72870
|
-
return bindings.filter((binding) => binding.type !== "secret_text").reduce((configObj, binding) => {
|
72871
|
-
switch (binding.type) {
|
72872
|
-
case "plain_text":
|
72873
|
-
{
|
72874
|
-
configObj.vars = {
|
72875
|
-
...configObj.vars ?? {},
|
72876
|
-
[binding.name]: binding.text
|
72877
|
-
};
|
72878
|
-
}
|
72879
|
-
break;
|
72880
|
-
case "json":
|
72881
|
-
{
|
72882
|
-
configObj.vars = {
|
72883
|
-
...configObj.vars ?? {},
|
72884
|
-
name: binding.name,
|
72885
|
-
json: binding.json
|
72886
|
-
};
|
72887
|
-
}
|
72888
|
-
break;
|
72889
|
-
case "kv_namespace":
|
72890
|
-
{
|
72891
|
-
configObj.kv_namespaces = [
|
72892
|
-
...configObj.kv_namespaces ?? [],
|
72893
|
-
{ id: binding.namespace_id, binding: binding.name }
|
72894
|
-
];
|
72895
|
-
}
|
72896
|
-
break;
|
72897
|
-
case "durable_object_namespace":
|
72898
|
-
{
|
72899
|
-
configObj.durable_objects = {
|
72900
|
-
bindings: [
|
72901
|
-
...configObj.durable_objects?.bindings ?? [],
|
72902
|
-
{
|
72903
|
-
name: binding.name,
|
72904
|
-
class_name: binding.class_name,
|
72905
|
-
script_name: binding.script_name,
|
72906
|
-
environment: binding.environment
|
72907
|
-
}
|
72908
|
-
]
|
72909
|
-
};
|
72910
|
-
}
|
72911
|
-
break;
|
72912
|
-
case "d1":
|
72913
|
-
{
|
72914
|
-
configObj.d1_databases = [
|
72915
|
-
...configObj.d1_databases ?? [],
|
72916
|
-
{
|
72917
|
-
binding: binding.name,
|
72918
|
-
database_id: binding.id,
|
72919
|
-
database_name: d1BindingsWithInfo[binding.id].name
|
72920
|
-
}
|
72921
|
-
];
|
72922
|
-
}
|
72923
|
-
break;
|
72924
|
-
case "browser":
|
72925
|
-
{
|
72926
|
-
configObj.browser = {
|
72927
|
-
binding: binding.name
|
72928
|
-
};
|
72929
|
-
}
|
72930
|
-
break;
|
72931
|
-
case "ai":
|
72932
|
-
{
|
72933
|
-
configObj.ai = {
|
72934
|
-
binding: binding.name
|
72935
|
-
};
|
72936
|
-
}
|
72937
|
-
break;
|
72938
|
-
case "images":
|
72939
|
-
{
|
72940
|
-
configObj.images = {
|
72941
|
-
binding: binding.name
|
72942
|
-
};
|
72943
|
-
}
|
72944
|
-
break;
|
72945
|
-
case "r2_bucket":
|
72946
|
-
{
|
72947
|
-
configObj.r2_buckets = [
|
72948
|
-
...configObj.r2_buckets ?? [],
|
72949
|
-
{
|
72950
|
-
binding: binding.name,
|
72951
|
-
bucket_name: binding.bucket_name,
|
72952
|
-
jurisdiction: binding.jurisdiction
|
72953
|
-
}
|
72954
|
-
];
|
72955
|
-
}
|
72956
|
-
break;
|
72957
|
-
case "secrets_store_secret":
|
72958
|
-
{
|
72959
|
-
configObj.secrets_store_secrets = [
|
72960
|
-
...configObj.secrets_store_secrets ?? [],
|
72961
|
-
{
|
72962
|
-
binding: binding.name,
|
72963
|
-
store_id: binding.store_id,
|
72964
|
-
secret_name: binding.secret_name
|
72965
|
-
}
|
72966
|
-
];
|
72967
|
-
}
|
72968
|
-
break;
|
72969
|
-
case "unsafe_hello_world": {
|
72970
|
-
configObj.unsafe_hello_world = [
|
72971
|
-
...configObj.unsafe_hello_world ?? [],
|
72972
|
-
{
|
72973
|
-
binding: binding.name,
|
72974
|
-
enable_timer: binding.enable_timer
|
72975
|
-
}
|
72976
|
-
];
|
72977
|
-
break;
|
72978
|
-
}
|
72979
|
-
case "service":
|
72980
|
-
{
|
72981
|
-
configObj.services = [
|
72982
|
-
...configObj.services ?? [],
|
72983
|
-
{
|
72984
|
-
binding: binding.name,
|
72985
|
-
service: binding.service,
|
72986
|
-
environment: binding.environment,
|
72987
|
-
entrypoint: binding.entrypoint
|
72988
|
-
}
|
72989
|
-
];
|
72990
|
-
}
|
72991
|
-
break;
|
72992
|
-
case "analytics_engine":
|
72993
|
-
{
|
72994
|
-
configObj.analytics_engine_datasets = [
|
72995
|
-
...configObj.analytics_engine_datasets ?? [],
|
72996
|
-
{ binding: binding.name, dataset: binding.dataset }
|
72997
|
-
];
|
72998
|
-
}
|
72999
|
-
break;
|
73000
|
-
case "dispatch_namespace":
|
73001
|
-
{
|
73002
|
-
configObj.dispatch_namespaces = [
|
73003
|
-
...configObj.dispatch_namespaces ?? [],
|
73004
|
-
{
|
73005
|
-
binding: binding.name,
|
73006
|
-
namespace: binding.namespace,
|
73007
|
-
...binding.outbound && {
|
73008
|
-
outbound: {
|
73009
|
-
service: binding.outbound.worker.service,
|
73010
|
-
environment: binding.outbound.worker.environment,
|
73011
|
-
parameters: binding.outbound.params?.map((p6) => p6.name) ?? []
|
73012
|
-
}
|
73013
|
-
}
|
73014
|
-
}
|
73015
|
-
];
|
73016
|
-
}
|
73017
|
-
break;
|
73018
|
-
case "logfwdr":
|
73019
|
-
{
|
73020
|
-
configObj.logfwdr = {
|
73021
|
-
bindings: [
|
73022
|
-
...configObj.logfwdr?.bindings ?? [],
|
73023
|
-
{ name: binding.name, destination: binding.destination }
|
73024
|
-
]
|
73025
|
-
};
|
73026
|
-
}
|
73027
|
-
break;
|
73028
|
-
case "wasm_module":
|
73029
|
-
{
|
73030
|
-
configObj.wasm_modules = {
|
73031
|
-
...configObj.wasm_modules ?? {},
|
73032
|
-
[binding.name]: binding.part
|
73033
|
-
};
|
73034
|
-
}
|
73035
|
-
break;
|
73036
|
-
case "text_blob":
|
73037
|
-
{
|
73038
|
-
configObj.text_blobs = {
|
73039
|
-
...configObj.text_blobs ?? {},
|
73040
|
-
[binding.name]: binding.part
|
73041
|
-
};
|
73042
|
-
}
|
73043
|
-
break;
|
73044
|
-
case "data_blob":
|
73045
|
-
{
|
73046
|
-
configObj.data_blobs = {
|
73047
|
-
...configObj.data_blobs ?? {},
|
73048
|
-
[binding.name]: binding.part
|
73049
|
-
};
|
73050
|
-
}
|
73051
|
-
break;
|
73052
|
-
case "secret_text":
|
73053
|
-
break;
|
73054
|
-
case "version_metadata": {
|
73055
|
-
{
|
73056
|
-
configObj.version_metadata = {
|
73057
|
-
binding: binding.name
|
73058
|
-
};
|
73059
|
-
}
|
73060
|
-
break;
|
73061
|
-
}
|
73062
|
-
case "send_email": {
|
73063
|
-
configObj.send_email = [
|
73064
|
-
...configObj.send_email ?? [],
|
73065
|
-
{
|
73066
|
-
name: binding.name,
|
73067
|
-
destination_address: binding.destination_address,
|
73068
|
-
allowed_destination_addresses: binding.allowed_destination_addresses
|
73069
|
-
}
|
73070
|
-
];
|
73071
|
-
break;
|
73072
|
-
}
|
73073
|
-
case "queue":
|
73074
|
-
configObj.queues ??= { producers: [] };
|
73075
|
-
configObj.queues.producers = [
|
73076
|
-
...configObj.queues.producers ?? [],
|
73077
|
-
{
|
73078
|
-
binding: binding.name,
|
73079
|
-
queue: binding.queue_name,
|
73080
|
-
delivery_delay: binding.delivery_delay
|
73081
|
-
}
|
73082
|
-
];
|
73083
|
-
break;
|
73084
|
-
case "vectorize":
|
73085
|
-
configObj.vectorize = [
|
73086
|
-
...configObj.vectorize ?? [],
|
73087
|
-
{
|
73088
|
-
binding: binding.name,
|
73089
|
-
index_name: binding.index_name
|
73090
|
-
}
|
73091
|
-
];
|
73092
|
-
break;
|
73093
|
-
case "hyperdrive":
|
73094
|
-
configObj.hyperdrive = [
|
73095
|
-
...configObj.hyperdrive ?? [],
|
73096
|
-
{
|
73097
|
-
binding: binding.name,
|
73098
|
-
id: binding.id
|
73099
|
-
}
|
73100
|
-
];
|
73101
|
-
break;
|
73102
|
-
case "mtls_certificate":
|
73103
|
-
configObj.mtls_certificates = [
|
73104
|
-
...configObj.mtls_certificates ?? [],
|
73105
|
-
{
|
73106
|
-
binding: binding.name,
|
73107
|
-
certificate_id: binding.certificate_id
|
73108
|
-
}
|
73109
|
-
];
|
73110
|
-
break;
|
73111
|
-
case "pipelines":
|
73112
|
-
configObj.pipelines = [
|
73113
|
-
...configObj.pipelines ?? [],
|
73114
|
-
{
|
73115
|
-
binding: binding.name,
|
73116
|
-
pipeline: binding.pipeline
|
73117
|
-
}
|
73118
|
-
];
|
73119
|
-
break;
|
73120
|
-
case "assets":
|
73121
|
-
throw new FatalError(
|
73122
|
-
"`wrangler init --from-dash` is not yet supported for Workers with Assets"
|
73123
|
-
);
|
73124
|
-
case "inherit":
|
73125
|
-
configObj.unsafe = {
|
73126
|
-
bindings: [...configObj.unsafe?.bindings ?? [], binding],
|
73127
|
-
metadata: configObj.unsafe?.metadata ?? void 0
|
73128
|
-
};
|
73129
|
-
break;
|
73130
|
-
case "workflow":
|
73131
|
-
{
|
73132
|
-
configObj.workflows = [
|
73133
|
-
...configObj.workflows ?? [],
|
73134
|
-
{
|
73135
|
-
binding: binding.name,
|
73136
|
-
name: binding.workflow_name,
|
73137
|
-
class_name: binding.class_name,
|
73138
|
-
script_name: binding.script_name
|
73139
|
-
}
|
73140
|
-
];
|
73141
|
-
}
|
73142
|
-
break;
|
73143
|
-
default: {
|
73144
|
-
configObj.unsafe = {
|
73145
|
-
bindings: [...configObj.unsafe?.bindings ?? [], binding],
|
73146
|
-
metadata: configObj.unsafe?.metadata ?? void 0
|
73147
|
-
};
|
73148
|
-
assertNever(binding);
|
73149
|
-
}
|
73150
|
-
}
|
73151
|
-
return configObj;
|
73152
|
-
}, {});
|
73153
|
-
}
|
73154
|
-
async function downloadWorker(accountId, workerName) {
|
73155
|
-
const serviceMetadata = await fetchResult(
|
73156
|
-
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
73157
|
-
`/accounts/${accountId}/workers/services/${workerName}`
|
73158
|
-
);
|
73159
|
-
const defaultEnvironment = serviceMetadata.default_environment.environment;
|
73160
|
-
const { entrypoint, modules } = await fetchWorkerDefinitionFromDash(
|
73161
|
-
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
73162
|
-
`/accounts/${accountId}/workers/services/${workerName}/environments/${defaultEnvironment}/content/v2`
|
73163
|
-
);
|
73164
|
-
const config = await downloadWorkerConfig(
|
73165
|
-
accountId,
|
73166
|
-
workerName,
|
73167
|
-
entrypoint,
|
73168
|
-
defaultEnvironment
|
73169
|
-
);
|
73170
|
-
return {
|
73171
|
-
modules,
|
73172
|
-
config
|
73173
|
-
};
|
73174
|
-
}
|
73175
|
-
var import_promises9, import_node_path27, import_toml5, init;
|
73176
|
-
var init_init = __esm({
|
73177
|
-
"src/init.ts"() {
|
73178
|
-
init_import_meta_url();
|
73179
|
-
import_promises9 = require("fs/promises");
|
73180
|
-
import_node_path27 = __toESM(require("path"));
|
73181
|
-
import_toml5 = __toESM(require_toml());
|
73182
|
-
init_execa();
|
73183
|
-
init_utils2();
|
73184
|
-
init_cfetch();
|
73185
|
-
init_internal();
|
73186
|
-
init_create_command();
|
73187
|
-
init_utils3();
|
73188
|
-
init_misc_variables();
|
73189
|
-
init_errors();
|
73190
|
-
init_logger();
|
73191
|
-
init_metrics_config();
|
73192
|
-
init_package_manager();
|
73193
|
-
init_user2();
|
73194
|
-
init_compatibility_date();
|
73195
|
-
init_create_batches();
|
73196
|
-
init_shell_quote();
|
73197
|
-
init = createCommand({
|
73198
|
-
metadata: {
|
73199
|
-
description: "\u{1F4E5} Initialize a basic Worker",
|
73200
|
-
owner: "Workers: Authoring and Testing",
|
73201
|
-
status: "stable"
|
73202
|
-
},
|
73203
|
-
args: {
|
73204
|
-
name: {
|
73205
|
-
describe: "The name of your worker",
|
73206
|
-
type: "string"
|
73207
|
-
},
|
73208
|
-
yes: {
|
73209
|
-
describe: 'Answer "yes" to any prompts for new projects',
|
73210
|
-
type: "boolean",
|
73211
|
-
alias: "y"
|
73212
|
-
},
|
73213
|
-
"from-dash": {
|
73214
|
-
describe: "The name of the Worker you wish to download from the Cloudflare dashboard for local development.",
|
73215
|
-
type: "string",
|
73216
|
-
requiresArg: true
|
73217
|
-
},
|
73218
|
-
"delegate-c3": {
|
73219
|
-
describe: "Delegate to Create Cloudflare CLI (C3)",
|
73220
|
-
type: "boolean",
|
73221
|
-
hidden: true,
|
73222
|
-
default: true,
|
73223
|
-
alias: "c3"
|
73224
|
-
}
|
73225
|
-
},
|
73226
|
-
behaviour: {
|
73227
|
-
provideConfig: false
|
73228
|
-
},
|
73229
|
-
positionalArgs: ["name"],
|
73230
|
-
async handler(args) {
|
73231
|
-
const yesFlag = args.yes ?? false;
|
73232
|
-
const packageManager = await getPackageManager();
|
73233
|
-
const name2 = args.fromDash ?? args.name;
|
73234
|
-
const c3Arguments = [
|
73235
|
-
...parse4(getC3CommandFromEnv()),
|
73236
|
-
...name2 ? [name2] : [],
|
73237
|
-
...yesFlag && isNpm(packageManager) ? ["-y"] : [],
|
73238
|
-
// --yes arg for npx
|
73239
|
-
...isNpm(packageManager) ? ["--"] : [],
|
73240
|
-
...args.fromDash ? ["--existing-script", args.fromDash] : [],
|
73241
|
-
...yesFlag ? ["--wrangler-defaults"] : []
|
73242
|
-
];
|
73243
|
-
const replacementC3Command = `\`${packageManager.type} ${c3Arguments.join(
|
73244
|
-
" "
|
73245
|
-
)}\``;
|
73246
|
-
if (args.fromDash && !args.delegateC3) {
|
73247
|
-
const accountId = await requireAuth({});
|
73248
|
-
try {
|
73249
|
-
await fetchResult(
|
73250
|
-
// `wrangler init` is not run from within a Workers project, so there will be no config file to define the compliance region.
|
73251
|
-
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
73252
|
-
`/accounts/${accountId}/workers/services/${args.fromDash}`
|
73253
|
-
);
|
73254
|
-
} catch (err) {
|
73255
|
-
if (err.code === 10090) {
|
73256
|
-
throw new UserError(
|
73257
|
-
"wrangler couldn't find a Worker with that name in your account.\nRun `wrangler whoami` to confirm you're logged into the correct account.",
|
73258
|
-
{
|
73259
|
-
telemetryMessage: true
|
73260
|
-
}
|
73261
|
-
);
|
73262
|
-
}
|
73263
|
-
throw err;
|
73264
|
-
}
|
73265
|
-
const creationDir = import_node_path27.default.join(process.cwd(), args.fromDash);
|
73266
|
-
await (0, import_promises9.mkdir)(creationDir, { recursive: true });
|
73267
|
-
const { modules, config } = await downloadWorker(
|
73268
|
-
accountId,
|
73269
|
-
args.fromDash
|
73270
|
-
);
|
73271
|
-
await (0, import_promises9.mkdir)(import_node_path27.default.join(creationDir, "./src"), {
|
73272
|
-
recursive: true
|
73273
|
-
});
|
73274
|
-
config.main = `src/${config.main}`;
|
73275
|
-
config.name = args.fromDash;
|
73276
|
-
for (const files of createBatches(modules, 10)) {
|
73277
|
-
await Promise.all(
|
73278
|
-
files.map(async (file) => {
|
73279
|
-
const filepath = import_node_path27.default.join(creationDir, `./src/${file.name}`);
|
73280
|
-
const directory = (0, import_node_path27.dirname)(filepath);
|
73281
|
-
await (0, import_promises9.mkdir)(directory, { recursive: true });
|
73282
|
-
await (0, import_promises9.writeFile)(filepath, file.stream());
|
73283
|
-
})
|
73284
|
-
);
|
73285
|
-
}
|
73286
|
-
await (0, import_promises9.writeFile)(
|
73287
|
-
import_node_path27.default.join(creationDir, "wrangler.toml"),
|
73288
|
-
import_toml5.default.stringify(config)
|
73289
|
-
);
|
73290
|
-
} else {
|
73291
|
-
logger.log(`\u{1F300} Running ${replacementC3Command}...`);
|
73292
|
-
const metricsConfig = readMetricsConfig();
|
73293
|
-
await execa(packageManager.type, c3Arguments, {
|
73294
|
-
stdio: "inherit",
|
73295
|
-
...metricsConfig.permission?.enabled === false && {
|
73296
|
-
env: { CREATE_CLOUDFLARE_TELEMETRY_DISABLED: "1" }
|
73297
|
-
}
|
73298
|
-
});
|
73299
|
-
}
|
73300
|
-
}
|
73301
|
-
});
|
73302
|
-
__name(isNpm, "isNpm");
|
73303
|
-
__name(downloadWorkerConfig, "downloadWorkerConfig");
|
73304
|
-
__name(mapBindings, "mapBindings");
|
73305
|
-
__name(downloadWorker, "downloadWorker");
|
73306
|
-
}
|
73307
|
-
});
|
73308
|
-
|
73309
72473
|
// ../../node_modules/.pnpm/xxhash-wasm@1.0.1/node_modules/xxhash-wasm/esm/xxhash-wasm.js
|
73310
72474
|
async function e() {
|
73311
72475
|
const { instance: { exports: { mem: e7, xxh32: n6, xxh64: r7, init32: i5, update32: o5, digest32: h6, init64: s5, update64: u5, digest64: g6 } } } = await WebAssembly.instantiate(t);
|
@@ -73373,7 +72537,7 @@ var init_xxhash_wasm = __esm({
|
|
73373
72537
|
|
73374
72538
|
// src/sites.ts
|
73375
72539
|
async function* getFilesInFolder(dirPath) {
|
73376
|
-
const files = await (0,
|
72540
|
+
const files = await (0, import_promises9.readdir)(dirPath, { withFileTypes: true });
|
73377
72541
|
for (const file of files) {
|
73378
72542
|
if (ALWAYS_IGNORE.has(file.name)) {
|
73379
72543
|
continue;
|
@@ -73382,9 +72546,9 @@ async function* getFilesInFolder(dirPath) {
|
|
73382
72546
|
continue;
|
73383
72547
|
}
|
73384
72548
|
if (file.isDirectory()) {
|
73385
|
-
yield* await getFilesInFolder(
|
72549
|
+
yield* await getFilesInFolder(path29.join(dirPath, file.name));
|
73386
72550
|
} else {
|
73387
|
-
yield
|
72551
|
+
yield path29.join(dirPath, file.name);
|
73388
72552
|
}
|
73389
72553
|
}
|
73390
72554
|
}
|
@@ -73392,11 +72556,11 @@ function hashFileContent(hasher, content) {
|
|
73392
72556
|
return hasher.h64ToString(content).substring(0, 10);
|
73393
72557
|
}
|
73394
72558
|
function hashAsset(hasher, filePath, content) {
|
73395
|
-
const extName =
|
73396
|
-
const baseName =
|
73397
|
-
const directory =
|
72559
|
+
const extName = path29.extname(filePath) || "";
|
72560
|
+
const baseName = path29.basename(filePath, extName);
|
72561
|
+
const directory = path29.dirname(filePath);
|
73398
72562
|
const hash = hashFileContent(hasher, content);
|
73399
|
-
return urlSafe(
|
72563
|
+
return urlSafe(path29.join(directory, `${baseName}.${hash}${extName}`));
|
73400
72564
|
}
|
73401
72565
|
async function createKVNamespaceIfNotAlreadyExisting(complianceConfig, title, accountId) {
|
73402
72566
|
const namespaces = await listKVNamespaces(complianceConfig, accountId);
|
@@ -73437,7 +72601,7 @@ async function syncWorkersSite(complianceConfig, accountId, scriptName, siteAsse
|
|
73437
72601
|
);
|
73438
72602
|
const namespaceKeyInfoMap = new Map(namespaceKeysResponse.map((x6) => [x6.name, x6]));
|
73439
72603
|
const namespaceKeys = new Set(namespaceKeysResponse.map((x6) => x6.name));
|
73440
|
-
const assetDirectory =
|
72604
|
+
const assetDirectory = path29.join(
|
73441
72605
|
siteAssets.baseDirectory,
|
73442
72606
|
siteAssets.assetDirectory
|
73443
72607
|
);
|
@@ -73466,11 +72630,11 @@ async function syncWorkersSite(complianceConfig, accountId, scriptName, siteAsse
|
|
73466
72630
|
__name(logDiff, "logDiff");
|
73467
72631
|
logger.info("Building list of assets to upload...");
|
73468
72632
|
for await (const absAssetFile of getFilesInFolder(assetDirectory)) {
|
73469
|
-
const assetFile =
|
72633
|
+
const assetFile = path29.relative(assetDirectory, absAssetFile);
|
73470
72634
|
if (!include(assetFile) || exclude2(assetFile)) {
|
73471
72635
|
continue;
|
73472
72636
|
}
|
73473
|
-
const content = await (0,
|
72637
|
+
const content = await (0, import_promises9.readFile)(absAssetFile, "base64");
|
73474
72638
|
const assetSize = Buffer.byteLength(content);
|
73475
72639
|
await validateAssetSize(absAssetFile, assetFile);
|
73476
72640
|
const assetKey = hashAsset(hasher, assetFile, content);
|
@@ -73492,7 +72656,7 @@ async function syncWorkersSite(complianceConfig, accountId, scriptName, siteAsse
|
|
73492
72656
|
skipCount++;
|
73493
72657
|
}
|
73494
72658
|
namespaceKeys.delete(assetKey);
|
73495
|
-
const manifestKey = urlSafe(
|
72659
|
+
const manifestKey = urlSafe(path29.relative(assetDirectory, absAssetFile));
|
73496
72660
|
manifest[manifestKey] = assetKey;
|
73497
72661
|
}
|
73498
72662
|
if (uploadBucket.length > 0) {
|
@@ -73525,7 +72689,7 @@ async function syncWorkersSite(complianceConfig, accountId, scriptName, siteAsse
|
|
73525
72689
|
for (const [absAssetFile, assetKey] of nextBucket) {
|
73526
72690
|
bucket.push({
|
73527
72691
|
key: assetKey,
|
73528
|
-
value: await (0,
|
72692
|
+
value: await (0, import_promises9.readFile)(absAssetFile, "base64"),
|
73529
72693
|
base64: true
|
73530
72694
|
});
|
73531
72695
|
if (controller.signal.aborted) {
|
@@ -73609,7 +72773,7 @@ async function syncWorkersSite(complianceConfig, accountId, scriptName, siteAsse
|
|
73609
72773
|
return { manifest, namespace };
|
73610
72774
|
}
|
73611
72775
|
async function validateAssetSize(absFilePath, relativeFilePath) {
|
73612
|
-
const { size } = await (0,
|
72776
|
+
const { size } = await (0, import_promises9.stat)(absFilePath);
|
73613
72777
|
if (size > 25 * 1024 * 1024) {
|
73614
72778
|
throw new UserError(
|
73615
72779
|
`File ${relativeFilePath} is too big, it should be under 25 MiB. See https://developers.cloudflare.com/workers/platform/limits#kv-limits`
|
@@ -73627,7 +72791,7 @@ function urlSafe(filePath) {
|
|
73627
72791
|
return filePath.replace(/\\/g, "/");
|
73628
72792
|
}
|
73629
72793
|
function getSiteAssetPaths(config, assetDirectory, includePatterns = config.site?.include ?? [], excludePatterns = config.site?.exclude ?? []) {
|
73630
|
-
const baseDirectory = assetDirectory ? process.cwd() :
|
72794
|
+
const baseDirectory = assetDirectory ? process.cwd() : path29.resolve(path29.dirname(config.configPath ?? "wrangler.toml"));
|
73631
72795
|
assetDirectory ??= config.site?.bucket;
|
73632
72796
|
if (assetDirectory) {
|
73633
72797
|
return {
|
@@ -73640,13 +72804,13 @@ function getSiteAssetPaths(config, assetDirectory, includePatterns = config.site
|
|
73640
72804
|
return void 0;
|
73641
72805
|
}
|
73642
72806
|
}
|
73643
|
-
var import_node_assert16,
|
72807
|
+
var import_node_assert16, import_promises9, path29, ALWAYS_IGNORE, HIDDEN_FILES_TO_INCLUDE, MAX_DIFF_LINES, MAX_BUCKET_SIZE2, MAX_BUCKET_KEYS, MAX_BATCH_OPERATIONS;
|
73644
72808
|
var init_sites = __esm({
|
73645
72809
|
"src/sites.ts"() {
|
73646
72810
|
init_import_meta_url();
|
73647
72811
|
import_node_assert16 = __toESM(require("assert"));
|
73648
|
-
|
73649
|
-
|
72812
|
+
import_promises9 = require("fs/promises");
|
72813
|
+
path29 = __toESM(require("path"));
|
73650
72814
|
init_workers_shared();
|
73651
72815
|
init_source();
|
73652
72816
|
init_xxhash_wasm();
|
@@ -73818,7 +72982,7 @@ async function retryOnAPIFailure(action, backoff = 0, attempts = MAX_ATTEMPTS) {
|
|
73818
72982
|
if (attempts <= 1) {
|
73819
72983
|
throw err;
|
73820
72984
|
}
|
73821
|
-
await (0,
|
72985
|
+
await (0, import_promises10.setTimeout)(backoff);
|
73822
72986
|
return retryOnAPIFailure(
|
73823
72987
|
action,
|
73824
72988
|
backoff + (MAX_ATTEMPTS - attempts) * 1e3,
|
@@ -73826,11 +72990,11 @@ async function retryOnAPIFailure(action, backoff = 0, attempts = MAX_ATTEMPTS) {
|
|
73826
72990
|
);
|
73827
72991
|
}
|
73828
72992
|
}
|
73829
|
-
var
|
72993
|
+
var import_promises10, MAX_ATTEMPTS;
|
73830
72994
|
var init_retry = __esm({
|
73831
72995
|
"src/utils/retry.ts"() {
|
73832
72996
|
init_import_meta_url();
|
73833
|
-
|
72997
|
+
import_promises10 = require("timers/promises");
|
73834
72998
|
init_source();
|
73835
72999
|
init_logger();
|
73836
73000
|
init_parse();
|
@@ -74030,10 +73194,6 @@ var init_zones = __esm({
|
|
74030
73194
|
});
|
74031
73195
|
|
74032
73196
|
// src/triggers/deploy.ts
|
74033
|
-
function getResolvedWorkersDev(configWorkersDev, routes) {
|
74034
|
-
const resolvedWorkersDev = configWorkersDev ?? routes.length === 0;
|
74035
|
-
return resolvedWorkersDev;
|
74036
|
-
}
|
74037
73197
|
async function triggersDeploy(props) {
|
74038
73198
|
const { config, accountId, name: scriptName } = props;
|
74039
73199
|
const schedules = props.triggers || config.triggers?.crons;
|
@@ -74048,7 +73208,6 @@ async function triggersDeploy(props) {
|
|
74048
73208
|
routesOnly.push(route);
|
74049
73209
|
}
|
74050
73210
|
}
|
74051
|
-
const deployToWorkersDev = getResolvedWorkersDev(config.workers_dev, routes);
|
74052
73211
|
if (!scriptName) {
|
74053
73212
|
throw new UserError(
|
74054
73213
|
'You need to provide a name when uploading a Worker Version. Either pass it as a cli arg with `--name <name>` or in your config file as `name = "<name>"`',
|
@@ -74060,10 +73219,6 @@ async function triggersDeploy(props) {
|
|
74060
73219
|
const notProd = Boolean(!props.legacyEnv && props.env);
|
74061
73220
|
const workerName = notProd ? `${scriptName} (${envName})` : scriptName;
|
74062
73221
|
const workerUrl = notProd ? `/accounts/${accountId}/workers/services/${scriptName}/environments/${envName}` : `/accounts/${accountId}/workers/scripts/${scriptName}`;
|
74063
|
-
const {
|
74064
|
-
enabled: available_on_subdomain,
|
74065
|
-
previews_enabled: previews_available_on_subdomain
|
74066
|
-
} = await fetchResult(config, `${workerUrl}/subdomain`);
|
74067
73222
|
if (!props.dryRun) {
|
74068
73223
|
await ensureQueuesExistByConfig(config);
|
74069
73224
|
}
|
@@ -74076,45 +73231,16 @@ async function triggersDeploy(props) {
|
|
74076
73231
|
}
|
74077
73232
|
const uploadMs = Date.now() - start;
|
74078
73233
|
const deployments = [];
|
74079
|
-
const
|
74080
|
-
|
74081
|
-
|
74082
|
-
|
74083
|
-
|
74084
|
-
|
74085
|
-
|
74086
|
-
|
74087
|
-
|
74088
|
-
|
74089
|
-
deployments.push(Promise.resolve([deploymentURL]));
|
74090
|
-
} else {
|
74091
|
-
deployments.push(
|
74092
|
-
fetchResult(config, `${workerUrl}/subdomain`, {
|
74093
|
-
method: "POST",
|
74094
|
-
body: JSON.stringify({
|
74095
|
-
enabled: true,
|
74096
|
-
previews_enabled: config.preview_urls
|
74097
|
-
}),
|
74098
|
-
headers: {
|
74099
|
-
"Content-Type": "application/json"
|
74100
|
-
}
|
74101
|
-
}).then(() => [deploymentURL])
|
74102
|
-
);
|
74103
|
-
}
|
74104
|
-
}
|
74105
|
-
if (!deployToWorkersDev && (!deploymentInSync || !previewsInSync)) {
|
74106
|
-
await fetchResult(config, `${workerUrl}/subdomain`, {
|
74107
|
-
method: "POST",
|
74108
|
-
body: JSON.stringify({
|
74109
|
-
enabled: false,
|
74110
|
-
previews_enabled: config.preview_urls
|
74111
|
-
}),
|
74112
|
-
headers: {
|
74113
|
-
"Content-Type": "application/json"
|
74114
|
-
}
|
74115
|
-
});
|
74116
|
-
}
|
74117
|
-
if (!deployToWorkersDev && deploymentInSync && routes.length !== 0) {
|
73234
|
+
const { wantWorkersDev, workersDevInSync } = await subdomainDeploy(
|
73235
|
+
props,
|
73236
|
+
accountId,
|
73237
|
+
scriptName,
|
73238
|
+
envName,
|
73239
|
+
workerUrl,
|
73240
|
+
routes,
|
73241
|
+
deployments
|
73242
|
+
);
|
73243
|
+
if (!wantWorkersDev && workersDevInSync && routes.length !== 0) {
|
74118
73244
|
const routesWithOtherBindings = {};
|
74119
73245
|
const queue = new PQueue({ concurrency: 10 });
|
74120
73246
|
const queuePromises = [];
|
@@ -74253,6 +73379,71 @@ ${dashLink}`);
|
|
74253
73379
|
logger.log("No deploy targets for", workerName, formatTime(deployMs));
|
74254
73380
|
}
|
74255
73381
|
}
|
73382
|
+
function getSubdomainValues(config_workers_dev, config_preview_urls, routes) {
|
73383
|
+
const defaultWorkersDev = routes.length === 0;
|
73384
|
+
const defaultPreviewUrls = false;
|
73385
|
+
return {
|
73386
|
+
workers_dev: config_workers_dev ?? defaultWorkersDev,
|
73387
|
+
preview_urls: config_preview_urls ?? defaultPreviewUrls
|
73388
|
+
};
|
73389
|
+
}
|
73390
|
+
async function subdomainDeploy(props, accountId, scriptName, envName, workerUrl, routes, deployments) {
|
73391
|
+
const { config } = props;
|
73392
|
+
const { workers_dev: wantWorkersDev, preview_urls: wantPreviews } = getSubdomainValues(config.workers_dev, config.preview_urls, routes);
|
73393
|
+
const { enabled: currWorkersDev, previews_enabled: currPreviews } = await fetchResult(config, `${workerUrl}/subdomain`);
|
73394
|
+
const workersDevInSync = wantWorkersDev === currWorkersDev;
|
73395
|
+
const previewsInSync = wantPreviews === currPreviews;
|
73396
|
+
const allInSync = [workersDevInSync, previewsInSync].every((v7) => v7);
|
73397
|
+
if (config.workers_dev == void 0 && !workersDevInSync) {
|
73398
|
+
const currWorkersDevStatus = currWorkersDev ? "enabled" : "disabled";
|
73399
|
+
logger.warn(
|
73400
|
+
[
|
73401
|
+
`Worker has workers.dev ${currWorkersDevStatus}, but 'workers_dev' is not in the config.`,
|
73402
|
+
`Using fallback value 'workers_dev = ${wantWorkersDev}'.`
|
73403
|
+
].join("\n")
|
73404
|
+
);
|
73405
|
+
}
|
73406
|
+
if (config.preview_urls == void 0 && !previewsInSync) {
|
73407
|
+
const currPreviewsStatus = currPreviews ? "enabled" : "disabled";
|
73408
|
+
logger.warn(
|
73409
|
+
[
|
73410
|
+
`Worker has preview URLs ${currPreviewsStatus}, but 'preview_urls' is not in the config.`,
|
73411
|
+
`Using fallback value 'preview_urls = ${wantPreviews}'.`
|
73412
|
+
].join("\n")
|
73413
|
+
);
|
73414
|
+
}
|
73415
|
+
let workersDevURL;
|
73416
|
+
if (wantWorkersDev) {
|
73417
|
+
const userSubdomain = await getWorkersDevSubdomain(
|
73418
|
+
config,
|
73419
|
+
accountId,
|
73420
|
+
config.configPath
|
73421
|
+
);
|
73422
|
+
workersDevURL = props.legacyEnv || !props.env ? `${scriptName}.${userSubdomain}` : `${envName}.${scriptName}.${userSubdomain}`;
|
73423
|
+
}
|
73424
|
+
if (!allInSync) {
|
73425
|
+
await fetchResult(config, `${workerUrl}/subdomain`, {
|
73426
|
+
method: "POST",
|
73427
|
+
body: JSON.stringify({
|
73428
|
+
enabled: wantWorkersDev,
|
73429
|
+
previews_enabled: wantPreviews
|
73430
|
+
}),
|
73431
|
+
headers: {
|
73432
|
+
"Content-Type": "application/json",
|
73433
|
+
"Cloudflare-Workers-Script-Api-Date": "2025-08-01"
|
73434
|
+
}
|
73435
|
+
});
|
73436
|
+
}
|
73437
|
+
if (workersDevURL) {
|
73438
|
+
deployments.push(Promise.resolve([workersDevURL]));
|
73439
|
+
}
|
73440
|
+
return {
|
73441
|
+
wantWorkersDev,
|
73442
|
+
wantPreviews,
|
73443
|
+
workersDevInSync,
|
73444
|
+
previewsInSync
|
73445
|
+
};
|
73446
|
+
}
|
74256
73447
|
var init_deploy3 = __esm({
|
74257
73448
|
"src/triggers/deploy.ts"() {
|
74258
73449
|
init_import_meta_url();
|
@@ -74266,8 +73457,446 @@ var init_deploy3 = __esm({
|
|
74266
73457
|
init_routes();
|
74267
73458
|
init_retry();
|
74268
73459
|
init_zones();
|
74269
|
-
__name(getResolvedWorkersDev, "getResolvedWorkersDev");
|
74270
73460
|
__name(triggersDeploy, "triggersDeploy");
|
73461
|
+
__name(getSubdomainValues, "getSubdomainValues");
|
73462
|
+
__name(subdomainDeploy, "subdomainDeploy");
|
73463
|
+
}
|
73464
|
+
});
|
73465
|
+
|
73466
|
+
// src/utils/compatibility-date.ts
|
73467
|
+
function getDevCompatibilityDate(config, compatibilityDate = config.compatibility_date) {
|
73468
|
+
const miniflareEntry = require.resolve("miniflare");
|
73469
|
+
const miniflareRequire = import_node_module3.default.createRequire(miniflareEntry);
|
73470
|
+
const miniflareWorkerd = miniflareRequire("workerd");
|
73471
|
+
const workerdDate = miniflareWorkerd.compatibilityDate;
|
73472
|
+
if (config.configPath !== void 0 && compatibilityDate === void 0) {
|
73473
|
+
logger.warn(
|
73474
|
+
`No compatibility_date was specified. Using the installed Workers runtime's latest supported date: ${workerdDate}.
|
73475
|
+
\u276F\u276F Add one to your ${configFileName(config.configPath)} file: compatibility_date = "${workerdDate}", or
|
73476
|
+
\u276F\u276F Pass it in your terminal: wrangler dev [<SCRIPT>] --compatibility-date=${workerdDate}
|
73477
|
+
|
73478
|
+
See https://developers.cloudflare.com/workers/platform/compatibility-dates/ for more information.`
|
73479
|
+
);
|
73480
|
+
}
|
73481
|
+
return compatibilityDate ?? workerdDate;
|
73482
|
+
}
|
73483
|
+
function formatCompatibilityDate(date) {
|
73484
|
+
return date.toISOString().slice(0, 10);
|
73485
|
+
}
|
73486
|
+
var import_node_module3;
|
73487
|
+
var init_compatibility_date = __esm({
|
73488
|
+
"src/utils/compatibility-date.ts"() {
|
73489
|
+
init_import_meta_url();
|
73490
|
+
import_node_module3 = __toESM(require("module"));
|
73491
|
+
init_config2();
|
73492
|
+
init_logger();
|
73493
|
+
__name(getDevCompatibilityDate, "getDevCompatibilityDate");
|
73494
|
+
__name(formatCompatibilityDate, "formatCompatibilityDate");
|
73495
|
+
}
|
73496
|
+
});
|
73497
|
+
|
73498
|
+
// src/utils/map-worker-metadata-bindings.ts
|
73499
|
+
async function mapWorkerMetadataBindings(bindings, accountId, complianceConfig) {
|
73500
|
+
const d1BindingsWithInfo = {};
|
73501
|
+
await Promise.all(
|
73502
|
+
bindings.filter((binding) => binding.type === "d1").map(async (binding) => {
|
73503
|
+
const dbInfo = await getDatabaseInfoFromIdOrName(
|
73504
|
+
complianceConfig,
|
73505
|
+
accountId,
|
73506
|
+
binding.id
|
73507
|
+
);
|
73508
|
+
d1BindingsWithInfo[binding.id] = dbInfo;
|
73509
|
+
})
|
73510
|
+
);
|
73511
|
+
return bindings.filter((binding) => binding.type !== "secret_text").reduce((configObj, binding) => {
|
73512
|
+
switch (binding.type) {
|
73513
|
+
case "plain_text":
|
73514
|
+
{
|
73515
|
+
configObj.vars = {
|
73516
|
+
...configObj.vars ?? {},
|
73517
|
+
[binding.name]: binding.text
|
73518
|
+
};
|
73519
|
+
}
|
73520
|
+
break;
|
73521
|
+
case "json":
|
73522
|
+
{
|
73523
|
+
configObj.vars = {
|
73524
|
+
...configObj.vars ?? {},
|
73525
|
+
name: binding.name,
|
73526
|
+
json: binding.json
|
73527
|
+
};
|
73528
|
+
}
|
73529
|
+
break;
|
73530
|
+
case "kv_namespace":
|
73531
|
+
{
|
73532
|
+
configObj.kv_namespaces = [
|
73533
|
+
...configObj.kv_namespaces ?? [],
|
73534
|
+
{ id: binding.namespace_id, binding: binding.name }
|
73535
|
+
];
|
73536
|
+
}
|
73537
|
+
break;
|
73538
|
+
case "durable_object_namespace":
|
73539
|
+
{
|
73540
|
+
configObj.durable_objects = {
|
73541
|
+
bindings: [
|
73542
|
+
...configObj.durable_objects?.bindings ?? [],
|
73543
|
+
{
|
73544
|
+
name: binding.name,
|
73545
|
+
class_name: binding.class_name,
|
73546
|
+
script_name: binding.script_name,
|
73547
|
+
environment: binding.environment
|
73548
|
+
}
|
73549
|
+
]
|
73550
|
+
};
|
73551
|
+
}
|
73552
|
+
break;
|
73553
|
+
case "d1":
|
73554
|
+
{
|
73555
|
+
configObj.d1_databases = [
|
73556
|
+
...configObj.d1_databases ?? [],
|
73557
|
+
{
|
73558
|
+
binding: binding.name,
|
73559
|
+
database_id: binding.id,
|
73560
|
+
database_name: d1BindingsWithInfo[binding.id].name
|
73561
|
+
}
|
73562
|
+
];
|
73563
|
+
}
|
73564
|
+
break;
|
73565
|
+
case "browser":
|
73566
|
+
{
|
73567
|
+
configObj.browser = {
|
73568
|
+
binding: binding.name
|
73569
|
+
};
|
73570
|
+
}
|
73571
|
+
break;
|
73572
|
+
case "ai":
|
73573
|
+
{
|
73574
|
+
configObj.ai = {
|
73575
|
+
binding: binding.name
|
73576
|
+
};
|
73577
|
+
}
|
73578
|
+
break;
|
73579
|
+
case "images":
|
73580
|
+
{
|
73581
|
+
configObj.images = {
|
73582
|
+
binding: binding.name
|
73583
|
+
};
|
73584
|
+
}
|
73585
|
+
break;
|
73586
|
+
case "r2_bucket":
|
73587
|
+
{
|
73588
|
+
configObj.r2_buckets = [
|
73589
|
+
...configObj.r2_buckets ?? [],
|
73590
|
+
{
|
73591
|
+
binding: binding.name,
|
73592
|
+
bucket_name: binding.bucket_name,
|
73593
|
+
jurisdiction: binding.jurisdiction
|
73594
|
+
}
|
73595
|
+
];
|
73596
|
+
}
|
73597
|
+
break;
|
73598
|
+
case "secrets_store_secret":
|
73599
|
+
{
|
73600
|
+
configObj.secrets_store_secrets = [
|
73601
|
+
...configObj.secrets_store_secrets ?? [],
|
73602
|
+
{
|
73603
|
+
binding: binding.name,
|
73604
|
+
store_id: binding.store_id,
|
73605
|
+
secret_name: binding.secret_name
|
73606
|
+
}
|
73607
|
+
];
|
73608
|
+
}
|
73609
|
+
break;
|
73610
|
+
case "unsafe_hello_world": {
|
73611
|
+
configObj.unsafe_hello_world = [
|
73612
|
+
...configObj.unsafe_hello_world ?? [],
|
73613
|
+
{
|
73614
|
+
binding: binding.name,
|
73615
|
+
enable_timer: binding.enable_timer
|
73616
|
+
}
|
73617
|
+
];
|
73618
|
+
break;
|
73619
|
+
}
|
73620
|
+
case "service":
|
73621
|
+
{
|
73622
|
+
configObj.services = [
|
73623
|
+
...configObj.services ?? [],
|
73624
|
+
{
|
73625
|
+
binding: binding.name,
|
73626
|
+
service: binding.service,
|
73627
|
+
environment: binding.environment,
|
73628
|
+
entrypoint: binding.entrypoint
|
73629
|
+
}
|
73630
|
+
];
|
73631
|
+
}
|
73632
|
+
break;
|
73633
|
+
case "analytics_engine":
|
73634
|
+
{
|
73635
|
+
configObj.analytics_engine_datasets = [
|
73636
|
+
...configObj.analytics_engine_datasets ?? [],
|
73637
|
+
{ binding: binding.name, dataset: binding.dataset }
|
73638
|
+
];
|
73639
|
+
}
|
73640
|
+
break;
|
73641
|
+
case "dispatch_namespace":
|
73642
|
+
{
|
73643
|
+
configObj.dispatch_namespaces = [
|
73644
|
+
...configObj.dispatch_namespaces ?? [],
|
73645
|
+
{
|
73646
|
+
binding: binding.name,
|
73647
|
+
namespace: binding.namespace,
|
73648
|
+
...binding.outbound && {
|
73649
|
+
outbound: {
|
73650
|
+
service: binding.outbound.worker.service,
|
73651
|
+
environment: binding.outbound.worker.environment,
|
73652
|
+
parameters: binding.outbound.params?.map((p6) => p6.name) ?? []
|
73653
|
+
}
|
73654
|
+
}
|
73655
|
+
}
|
73656
|
+
];
|
73657
|
+
}
|
73658
|
+
break;
|
73659
|
+
case "logfwdr":
|
73660
|
+
{
|
73661
|
+
configObj.logfwdr = {
|
73662
|
+
bindings: [
|
73663
|
+
...configObj.logfwdr?.bindings ?? [],
|
73664
|
+
{ name: binding.name, destination: binding.destination }
|
73665
|
+
]
|
73666
|
+
};
|
73667
|
+
}
|
73668
|
+
break;
|
73669
|
+
case "wasm_module":
|
73670
|
+
{
|
73671
|
+
configObj.wasm_modules = {
|
73672
|
+
...configObj.wasm_modules ?? {},
|
73673
|
+
[binding.name]: binding.part
|
73674
|
+
};
|
73675
|
+
}
|
73676
|
+
break;
|
73677
|
+
case "text_blob":
|
73678
|
+
{
|
73679
|
+
configObj.text_blobs = {
|
73680
|
+
...configObj.text_blobs ?? {},
|
73681
|
+
[binding.name]: binding.part
|
73682
|
+
};
|
73683
|
+
}
|
73684
|
+
break;
|
73685
|
+
case "data_blob":
|
73686
|
+
{
|
73687
|
+
configObj.data_blobs = {
|
73688
|
+
...configObj.data_blobs ?? {},
|
73689
|
+
[binding.name]: binding.part
|
73690
|
+
};
|
73691
|
+
}
|
73692
|
+
break;
|
73693
|
+
case "secret_text":
|
73694
|
+
break;
|
73695
|
+
case "version_metadata": {
|
73696
|
+
{
|
73697
|
+
configObj.version_metadata = {
|
73698
|
+
binding: binding.name
|
73699
|
+
};
|
73700
|
+
}
|
73701
|
+
break;
|
73702
|
+
}
|
73703
|
+
case "send_email": {
|
73704
|
+
configObj.send_email = [
|
73705
|
+
...configObj.send_email ?? [],
|
73706
|
+
{
|
73707
|
+
name: binding.name,
|
73708
|
+
destination_address: binding.destination_address,
|
73709
|
+
allowed_destination_addresses: binding.allowed_destination_addresses
|
73710
|
+
}
|
73711
|
+
];
|
73712
|
+
break;
|
73713
|
+
}
|
73714
|
+
case "queue":
|
73715
|
+
configObj.queues ??= { producers: [] };
|
73716
|
+
configObj.queues.producers = [
|
73717
|
+
...configObj.queues.producers ?? [],
|
73718
|
+
{
|
73719
|
+
binding: binding.name,
|
73720
|
+
queue: binding.queue_name,
|
73721
|
+
delivery_delay: binding.delivery_delay
|
73722
|
+
}
|
73723
|
+
];
|
73724
|
+
break;
|
73725
|
+
case "vectorize":
|
73726
|
+
configObj.vectorize = [
|
73727
|
+
...configObj.vectorize ?? [],
|
73728
|
+
{
|
73729
|
+
binding: binding.name,
|
73730
|
+
index_name: binding.index_name
|
73731
|
+
}
|
73732
|
+
];
|
73733
|
+
break;
|
73734
|
+
case "hyperdrive":
|
73735
|
+
configObj.hyperdrive = [
|
73736
|
+
...configObj.hyperdrive ?? [],
|
73737
|
+
{
|
73738
|
+
binding: binding.name,
|
73739
|
+
id: binding.id
|
73740
|
+
}
|
73741
|
+
];
|
73742
|
+
break;
|
73743
|
+
case "mtls_certificate":
|
73744
|
+
configObj.mtls_certificates = [
|
73745
|
+
...configObj.mtls_certificates ?? [],
|
73746
|
+
{
|
73747
|
+
binding: binding.name,
|
73748
|
+
certificate_id: binding.certificate_id
|
73749
|
+
}
|
73750
|
+
];
|
73751
|
+
break;
|
73752
|
+
case "pipelines":
|
73753
|
+
configObj.pipelines = [
|
73754
|
+
...configObj.pipelines ?? [],
|
73755
|
+
{
|
73756
|
+
binding: binding.name,
|
73757
|
+
pipeline: binding.pipeline
|
73758
|
+
}
|
73759
|
+
];
|
73760
|
+
break;
|
73761
|
+
case "assets":
|
73762
|
+
throw new FatalError(
|
73763
|
+
"`wrangler init --from-dash` is not yet supported for Workers with Assets"
|
73764
|
+
);
|
73765
|
+
case "inherit":
|
73766
|
+
configObj.unsafe = {
|
73767
|
+
bindings: [...configObj.unsafe?.bindings ?? [], binding],
|
73768
|
+
metadata: configObj.unsafe?.metadata ?? void 0
|
73769
|
+
};
|
73770
|
+
break;
|
73771
|
+
case "workflow":
|
73772
|
+
{
|
73773
|
+
configObj.workflows = [
|
73774
|
+
...configObj.workflows ?? [],
|
73775
|
+
{
|
73776
|
+
binding: binding.name,
|
73777
|
+
name: binding.workflow_name,
|
73778
|
+
class_name: binding.class_name,
|
73779
|
+
script_name: binding.script_name
|
73780
|
+
}
|
73781
|
+
];
|
73782
|
+
}
|
73783
|
+
break;
|
73784
|
+
default: {
|
73785
|
+
configObj.unsafe = {
|
73786
|
+
bindings: [...configObj.unsafe?.bindings ?? [], binding],
|
73787
|
+
metadata: configObj.unsafe?.metadata ?? void 0
|
73788
|
+
};
|
73789
|
+
assertNever(binding);
|
73790
|
+
}
|
73791
|
+
}
|
73792
|
+
return configObj;
|
73793
|
+
}, {});
|
73794
|
+
}
|
73795
|
+
var init_map_worker_metadata_bindings = __esm({
|
73796
|
+
"src/utils/map-worker-metadata-bindings.ts"() {
|
73797
|
+
init_import_meta_url();
|
73798
|
+
init_utils3();
|
73799
|
+
init_errors();
|
73800
|
+
init_assert_never();
|
73801
|
+
__name(mapWorkerMetadataBindings, "mapWorkerMetadataBindings");
|
73802
|
+
}
|
73803
|
+
});
|
73804
|
+
|
73805
|
+
// src/utils/download-worker-config.ts
|
73806
|
+
async function downloadWorkerConfig(workerName, environment, entrypoint, accountId) {
|
73807
|
+
const [
|
73808
|
+
bindings,
|
73809
|
+
routes,
|
73810
|
+
customDomains,
|
73811
|
+
subdomainStatus,
|
73812
|
+
serviceEnvMetadata,
|
73813
|
+
cronTriggers
|
73814
|
+
] = await Promise.all([
|
73815
|
+
fetchResult(
|
73816
|
+
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
73817
|
+
`/accounts/${accountId}/workers/services/${workerName}/environments/${environment}/bindings`
|
73818
|
+
),
|
73819
|
+
fetchResult(
|
73820
|
+
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
73821
|
+
`/accounts/${accountId}/workers/services/${workerName}/environments/${environment}/routes?show_zonename=true`
|
73822
|
+
),
|
73823
|
+
fetchResult(
|
73824
|
+
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
73825
|
+
`/accounts/${accountId}/workers/domains/records?page=0&per_page=5&service=${workerName}&environment=${environment}`
|
73826
|
+
),
|
73827
|
+
fetchResult(
|
73828
|
+
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
73829
|
+
`/accounts/${accountId}/workers/services/${workerName}/environments/${environment}/subdomain`
|
73830
|
+
),
|
73831
|
+
fetchResult(
|
73832
|
+
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
73833
|
+
`/accounts/${accountId}/workers/services/${workerName}/environments/${environment}`
|
73834
|
+
),
|
73835
|
+
fetchResult(
|
73836
|
+
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
73837
|
+
`/accounts/${accountId}/workers/scripts/${workerName}/schedules`
|
73838
|
+
)
|
73839
|
+
]).catch((e7) => {
|
73840
|
+
throw new Error(
|
73841
|
+
`Error Occurred: Unable to fetch bindings, routes, or services metadata from the dashboard. Please try again later.`,
|
73842
|
+
{ cause: e7 }
|
73843
|
+
);
|
73844
|
+
});
|
73845
|
+
const mappedBindings = await mapWorkerMetadataBindings(
|
73846
|
+
bindings,
|
73847
|
+
accountId,
|
73848
|
+
COMPLIANCE_REGION_CONFIG_UNKNOWN
|
73849
|
+
);
|
73850
|
+
const durableObjectClassNames = bindings.filter((binding) => binding.type === "durable_object_namespace").map(
|
73851
|
+
(durableObject) => durableObject.class_name
|
73852
|
+
);
|
73853
|
+
const allRoutes = [
|
73854
|
+
...routes.map((r7) => ({
|
73855
|
+
pattern: r7.pattern,
|
73856
|
+
zone_name: r7.zone_name
|
73857
|
+
})),
|
73858
|
+
...customDomains.map((c6) => ({
|
73859
|
+
pattern: c6.hostname,
|
73860
|
+
zone_name: c6.zone_name,
|
73861
|
+
custom_domain: true
|
73862
|
+
}))
|
73863
|
+
];
|
73864
|
+
return {
|
73865
|
+
name: workerName,
|
73866
|
+
main: entrypoint,
|
73867
|
+
workers_dev: subdomainStatus.enabled,
|
73868
|
+
preview_urls: subdomainStatus.previews_enabled,
|
73869
|
+
compatibility_date: serviceEnvMetadata.script.compatibility_date ?? formatCompatibilityDate(/* @__PURE__ */ new Date()),
|
73870
|
+
compatibility_flags: serviceEnvMetadata.script.compatibility_flags,
|
73871
|
+
...allRoutes.length ? { routes: allRoutes } : {},
|
73872
|
+
placement: serviceEnvMetadata.script.placement_mode === "smart" ? { mode: "smart" } : void 0,
|
73873
|
+
limits: serviceEnvMetadata.script.limits,
|
73874
|
+
...durableObjectClassNames.length ? {
|
73875
|
+
migrations: [
|
73876
|
+
{
|
73877
|
+
tag: serviceEnvMetadata.script.migration_tag,
|
73878
|
+
new_classes: durableObjectClassNames
|
73879
|
+
}
|
73880
|
+
]
|
73881
|
+
} : {},
|
73882
|
+
...cronTriggers.schedules.length ? {
|
73883
|
+
triggers: {
|
73884
|
+
crons: cronTriggers.schedules.map((scheduled) => scheduled.cron)
|
73885
|
+
}
|
73886
|
+
} : {},
|
73887
|
+
tail_consumers: serviceEnvMetadata.script.tail_consumers ?? void 0,
|
73888
|
+
observability: serviceEnvMetadata.script.observability,
|
73889
|
+
...mappedBindings
|
73890
|
+
};
|
73891
|
+
}
|
73892
|
+
var init_download_worker_config = __esm({
|
73893
|
+
"src/utils/download-worker-config.ts"() {
|
73894
|
+
init_import_meta_url();
|
73895
|
+
init_cfetch();
|
73896
|
+
init_misc_variables();
|
73897
|
+
init_compatibility_date();
|
73898
|
+
init_map_worker_metadata_bindings();
|
73899
|
+
__name(downloadWorkerConfig, "downloadWorkerConfig");
|
74271
73900
|
}
|
74272
73901
|
});
|
74273
73902
|
|
@@ -82082,6 +81711,16 @@ function containerAppToInstanceType(containerApp) {
|
|
82082
81711
|
}
|
82083
81712
|
return configuration;
|
82084
81713
|
}
|
81714
|
+
function convertContainerAffinitiesForApi2(container) {
|
81715
|
+
if (container.affinities === void 0) {
|
81716
|
+
return void 0;
|
81717
|
+
}
|
81718
|
+
const affinities = {
|
81719
|
+
colocation: container.affinities?.colocation,
|
81720
|
+
hardware_generation: container.affinities?.hardware_generation
|
81721
|
+
};
|
81722
|
+
return affinities;
|
81723
|
+
}
|
82085
81724
|
function containerAppToCreateApplication(accountId, containerApp, observability, existingApp, skipDefaults = false) {
|
82086
81725
|
const observabilityConfiguration = observabilityToConfiguration2(
|
82087
81726
|
observability,
|
@@ -82116,7 +81755,8 @@ function containerAppToCreateApplication(accountId, containerApp, observability,
|
|
82116
81755
|
regions: containerApp.constraints?.regions?.map(
|
82117
81756
|
(region) => region.toUpperCase()
|
82118
81757
|
)
|
82119
|
-
}
|
81758
|
+
},
|
81759
|
+
affinities: convertContainerAffinitiesForApi2(containerApp)
|
82120
81760
|
};
|
82121
81761
|
delete app["class_name"];
|
82122
81762
|
delete app["image"];
|
@@ -82401,9 +82041,9 @@ var init_apply = __esm({
|
|
82401
82041
|
init_deploy();
|
82402
82042
|
init_errors();
|
82403
82043
|
init_user2();
|
82044
|
+
init_diff();
|
82404
82045
|
init_sortObjectRecursive();
|
82405
82046
|
init_common();
|
82406
|
-
init_diff();
|
82407
82047
|
init_instance_type();
|
82408
82048
|
__name(mergeDeep3, "mergeDeep");
|
82409
82049
|
__name(isObject2, "isObject");
|
@@ -82413,6 +82053,7 @@ var init_apply = __esm({
|
|
82413
82053
|
__name(cleanupObservability2, "cleanupObservability");
|
82414
82054
|
__name(observabilityToConfiguration2, "observabilityToConfiguration");
|
82415
82055
|
__name(containerAppToInstanceType, "containerAppToInstanceType");
|
82056
|
+
__name(convertContainerAffinitiesForApi2, "convertContainerAffinitiesForApi");
|
82416
82057
|
__name(containerAppToCreateApplication, "containerAppToCreateApplication");
|
82417
82058
|
__name(apply2, "apply");
|
82418
82059
|
__name(applyCommand, "applyCommand");
|
@@ -82949,7 +82590,7 @@ function createSSHPublicKeyOptionalYargs(yargs) {
|
|
82949
82590
|
}
|
82950
82591
|
async function retrieveSSHKey(sshKeyPath, { json } = { json: false }) {
|
82951
82592
|
try {
|
82952
|
-
const file = (await (0,
|
82593
|
+
const file = (await (0, import_promises11.readFile)(sshKeyPath)).toString();
|
82953
82594
|
validatePublicSSHKeyCLI(file, { json });
|
82954
82595
|
return file;
|
82955
82596
|
} catch {
|
@@ -82990,10 +82631,10 @@ async function tryToRetrieveAllDefaultSSHKeyPaths() {
|
|
82990
82631
|
const path72 = `${HOME}/.ssh`;
|
82991
82632
|
const paths = [];
|
82992
82633
|
try {
|
82993
|
-
const dirList = await (0,
|
82634
|
+
const dirList = await (0, import_promises11.readdir)(path72);
|
82994
82635
|
for (const file of dirList) {
|
82995
82636
|
if (file.endsWith(".pub")) {
|
82996
|
-
const s5 = await (0,
|
82637
|
+
const s5 = await (0, import_promises11.stat)(`${path72}/${file}`);
|
82997
82638
|
if (s5.isFile()) {
|
82998
82639
|
paths.push(`${path72}/${file}`);
|
82999
82640
|
}
|
@@ -83032,7 +82673,7 @@ async function shouldPromptForNewSSHKeyAppear(keys = void 0) {
|
|
83032
82673
|
}
|
83033
82674
|
let foundValidSSHKeyThatDontExist = false;
|
83034
82675
|
for (const defaultSSHKeyPath of defaultSSHKeyPaths) {
|
83035
|
-
const file = (await (0,
|
82676
|
+
const file = (await (0, import_promises11.readFile)(defaultSSHKeyPath)).toString().trim();
|
83036
82677
|
try {
|
83037
82678
|
validateSSHKey(file);
|
83038
82679
|
} catch {
|
@@ -83145,11 +82786,11 @@ async function promptForSSHKey(args) {
|
|
83145
82786
|
}
|
83146
82787
|
return res;
|
83147
82788
|
}
|
83148
|
-
var
|
82789
|
+
var import_promises11, import_os4, sshCommand;
|
83149
82790
|
var init_ssh = __esm({
|
83150
82791
|
"src/cloudchamber/ssh/ssh.ts"() {
|
83151
82792
|
init_import_meta_url();
|
83152
|
-
|
82793
|
+
import_promises11 = require("fs/promises");
|
83153
82794
|
import_os4 = require("os");
|
83154
82795
|
init_cli();
|
83155
82796
|
init_colors();
|
@@ -85576,7 +85217,7 @@ async function executeLocally({
|
|
85576
85217
|
}
|
85577
85218
|
const id = localDB.previewDatabaseUuid ?? localDB.uuid;
|
85578
85219
|
const persistencePath = getLocalPersistencePath(persistTo, config);
|
85579
|
-
const d1Persist =
|
85220
|
+
const d1Persist = import_node_path27.default.join(persistencePath, "v3", "d1");
|
85580
85221
|
logger.log(
|
85581
85222
|
`\u{1F300} Executing on local database ${name2} (${id}) from ${readableRelative(
|
85582
85223
|
d1Persist
|
@@ -85857,13 +85498,13 @@ async function checkForSQLiteBinary(filename) {
|
|
85857
85498
|
);
|
85858
85499
|
}
|
85859
85500
|
}
|
85860
|
-
var import_fs16, import_node_assert17,
|
85501
|
+
var import_fs16, import_node_assert17, import_node_path27, import_md5_file, import_miniflare12, import_undici8, d1ExecuteCommand;
|
85861
85502
|
var init_execute = __esm({
|
85862
85503
|
"src/d1/execute.ts"() {
|
85863
85504
|
init_import_meta_url();
|
85864
85505
|
import_fs16 = require("fs");
|
85865
85506
|
import_node_assert17 = __toESM(require("assert"));
|
85866
|
-
|
85507
|
+
import_node_path27 = __toESM(require("path"));
|
85867
85508
|
init_interactive();
|
85868
85509
|
init_source();
|
85869
85510
|
import_md5_file = __toESM(require_md5_file());
|
@@ -86033,7 +85674,7 @@ async function exportLocal(config, name2, output, tables, noSchema, noData) {
|
|
86033
85674
|
}
|
86034
85675
|
const id = localDB.previewDatabaseUuid ?? localDB.uuid;
|
86035
85676
|
const persistencePath = getLocalPersistencePath(void 0, config);
|
86036
|
-
const d1Persist =
|
85677
|
+
const d1Persist = import_node_path28.default.join(persistencePath, "v3", "d1");
|
86037
85678
|
logger.log(
|
86038
85679
|
`\u{1F300} Exporting local database ${name2} (${id}) from ${readableRelative(
|
86039
85680
|
d1Persist
|
@@ -86052,7 +85693,7 @@ async function exportLocal(config, name2, output, tables, noSchema, noData) {
|
|
86052
85693
|
logger.log(`\u{1F300} Exporting SQL to ${output}...`);
|
86053
85694
|
try {
|
86054
85695
|
const dump = await db.prepare(`PRAGMA miniflare_d1_export(?,?,?);`).bind(noSchema, noData, ...tables).raw();
|
86055
|
-
await
|
85696
|
+
await import_promises12.default.writeFile(output, dump[0].join("\n"));
|
86056
85697
|
} catch (e7) {
|
86057
85698
|
throw new UserError(e7.message);
|
86058
85699
|
} finally {
|
@@ -86096,7 +85737,7 @@ async function exportRemotely(config, name2, output, tables, noSchema, noData) {
|
|
86096
85737
|
`There was an error while downloading from the presigned URL with status code: ${contents.status}`
|
86097
85738
|
);
|
86098
85739
|
}
|
86099
|
-
await
|
85740
|
+
await import_promises12.default.writeFile(output, contents.body || "");
|
86100
85741
|
}
|
86101
85742
|
});
|
86102
85743
|
logger.log(`\u{1F300} Downloaded to ${output} successfully!`);
|
@@ -86147,12 +85788,12 @@ async function pollExport(s5, complianceConfig, accountId, db, dumpOptions, curr
|
|
86147
85788
|
);
|
86148
85789
|
}
|
86149
85790
|
}
|
86150
|
-
var
|
85791
|
+
var import_promises12, import_node_path28, import_miniflare13, import_undici9, d1ExportCommand;
|
86151
85792
|
var init_export = __esm({
|
86152
85793
|
"src/d1/export.ts"() {
|
86153
85794
|
init_import_meta_url();
|
86154
|
-
|
86155
|
-
|
85795
|
+
import_promises12 = __toESM(require("fs/promises"));
|
85796
|
+
import_node_path28 = __toESM(require("path"));
|
86156
85797
|
init_interactive();
|
86157
85798
|
init_source();
|
86158
85799
|
import_miniflare13 = require("miniflare");
|
@@ -87603,10 +87244,10 @@ var init_delete3 = __esm({
|
|
87603
87244
|
|
87604
87245
|
// src/deployment-bundle/guess-worker-format.ts
|
87605
87246
|
async function guessWorkerFormat(entryFile, entryWorkingDirectory, tsconfig) {
|
87606
|
-
const parsedEntryPath =
|
87247
|
+
const parsedEntryPath = import_node_path29.default.parse(entryFile);
|
87607
87248
|
if (parsedEntryPath.ext == ".py") {
|
87608
87249
|
logger.warn(
|
87609
|
-
`The entrypoint ${
|
87250
|
+
`The entrypoint ${import_node_path29.default.relative(
|
87610
87251
|
process.cwd(),
|
87611
87252
|
entryFile
|
87612
87253
|
)} defines a Python worker, support for Python workers is currently experimental.`
|
@@ -87631,7 +87272,7 @@ async function guessWorkerFormat(entryFile, entryWorkingDirectory, tsconfig) {
|
|
87631
87272
|
guessedWorkerFormat = "modules";
|
87632
87273
|
} else {
|
87633
87274
|
logger.warn(
|
87634
|
-
`The entrypoint ${
|
87275
|
+
`The entrypoint ${import_node_path29.default.relative(
|
87635
87276
|
process.cwd(),
|
87636
87277
|
entryFile
|
87637
87278
|
)} has exports like an ES Module, but hasn't defined a default export like a module worker normally would. Building the worker using "service-worker" format...`
|
@@ -87643,11 +87284,11 @@ async function guessWorkerFormat(entryFile, entryWorkingDirectory, tsconfig) {
|
|
87643
87284
|
}
|
87644
87285
|
return { format: guessedWorkerFormat, exports: exports2 };
|
87645
87286
|
}
|
87646
|
-
var
|
87287
|
+
var import_node_path29, esbuild2;
|
87647
87288
|
var init_guess_worker_format = __esm({
|
87648
87289
|
"src/deployment-bundle/guess-worker-format.ts"() {
|
87649
87290
|
init_import_meta_url();
|
87650
|
-
|
87291
|
+
import_node_path29 = __toESM(require("path"));
|
87651
87292
|
esbuild2 = __toESM(require("esbuild"));
|
87652
87293
|
init_logger();
|
87653
87294
|
init_bundle();
|
@@ -87777,7 +87418,7 @@ ${migrateUrl}`,
|
|
87777
87418
|
projectRoot,
|
87778
87419
|
configPath: config.configPath,
|
87779
87420
|
format: format9,
|
87780
|
-
moduleRoot: args.moduleRoot ?? config.base_dir ??
|
87421
|
+
moduleRoot: args.moduleRoot ?? config.base_dir ?? import_node_path30.default.dirname(paths.absolutePath),
|
87781
87422
|
name: config.name ?? "worker",
|
87782
87423
|
exports: exports2
|
87783
87424
|
};
|
@@ -87817,11 +87458,11 @@ function getNpxEquivalent() {
|
|
87817
87458
|
return "npx";
|
87818
87459
|
}
|
87819
87460
|
}
|
87820
|
-
var
|
87461
|
+
var import_node_path30;
|
87821
87462
|
var init_entry = __esm({
|
87822
87463
|
"src/deployment-bundle/entry.ts"() {
|
87823
87464
|
init_import_meta_url();
|
87824
|
-
|
87465
|
+
import_node_path30 = __toESM(require("path"));
|
87825
87466
|
init_esm2();
|
87826
87467
|
init_config2();
|
87827
87468
|
init_errors();
|
@@ -87924,20 +87565,20 @@ function getOutputFilePath() {
|
|
87924
87565
|
const outputFileDirectoryFromEnv = getOutputFileDirectoryFromEnv();
|
87925
87566
|
if (outputFileDirectoryFromEnv) {
|
87926
87567
|
const date = (/* @__PURE__ */ new Date()).toISOString().replaceAll(":", "-").replace(".", "_").replace("T", "_").replace("Z", "");
|
87927
|
-
return (0,
|
87568
|
+
return (0, import_node_path31.resolve)(
|
87928
87569
|
outputFileDirectoryFromEnv,
|
87929
87570
|
`wrangler-output-${date}-${(0, import_node_crypto6.randomBytes)(3).toString("hex")}.json`
|
87930
87571
|
);
|
87931
87572
|
}
|
87932
87573
|
return null;
|
87933
87574
|
}
|
87934
|
-
var import_node_crypto6, import_node_fs19,
|
87575
|
+
var import_node_crypto6, import_node_fs19, import_node_path31, outputFilePath;
|
87935
87576
|
var init_output = __esm({
|
87936
87577
|
"src/output.ts"() {
|
87937
87578
|
init_import_meta_url();
|
87938
87579
|
import_node_crypto6 = require("crypto");
|
87939
87580
|
import_node_fs19 = require("fs");
|
87940
|
-
|
87581
|
+
import_node_path31 = require("path");
|
87941
87582
|
init_misc_variables();
|
87942
87583
|
init_filesystem();
|
87943
87584
|
__name(writeOutput, "writeOutput");
|
@@ -88003,7 +87644,7 @@ async function handleMaybeAssetsDeployment(assetDirectory, args) {
|
|
88003
87644
|
}
|
88004
87645
|
}
|
88005
87646
|
if (!args.name) {
|
88006
|
-
const defaultName = process.cwd().split(
|
87647
|
+
const defaultName = process.cwd().split(import_node_path32.default.sep).pop()?.replace("_", "-");
|
88007
87648
|
const isValidName2 = defaultName && /^[a-zA-Z0-9-]+$/.test(defaultName);
|
88008
87649
|
const projectName = await prompt("What do you want to name your project?", {
|
88009
87650
|
defaultValue: isValidName2 ? defaultName : "my-project"
|
@@ -88025,7 +87666,7 @@ async function handleMaybeAssetsDeployment(assetDirectory, args) {
|
|
88025
87666
|
${source_default.dim("This will allow you to simply run `wrangler deploy` on future deployments.")}`
|
88026
87667
|
);
|
88027
87668
|
if (writeConfig) {
|
88028
|
-
const configPath =
|
87669
|
+
const configPath = import_node_path32.default.join(process.cwd(), "wrangler.jsonc");
|
88029
87670
|
const jsonString = JSON.stringify(
|
88030
87671
|
{
|
88031
87672
|
name: args.name,
|
@@ -88052,13 +87693,13 @@ ${jsonString}
|
|
88052
87693
|
logger.log("\nProceeding with deployment...\n");
|
88053
87694
|
return args;
|
88054
87695
|
}
|
88055
|
-
var import_node_assert18, import_node_fs20,
|
87696
|
+
var import_node_assert18, import_node_fs20, import_node_path32, deployCommand;
|
88056
87697
|
var init_deploy4 = __esm({
|
88057
87698
|
"src/deploy/index.ts"() {
|
88058
87699
|
init_import_meta_url();
|
88059
87700
|
import_node_assert18 = __toESM(require("assert"));
|
88060
87701
|
import_node_fs20 = require("fs");
|
88061
|
-
|
87702
|
+
import_node_path32 = __toESM(require("path"));
|
88062
87703
|
init_source();
|
88063
87704
|
init_assets();
|
88064
87705
|
init_config2();
|
@@ -88309,7 +87950,7 @@ var init_deploy4 = __esm({
|
|
88309
87950
|
{ telemetryMessage: true }
|
88310
87951
|
);
|
88311
87952
|
}
|
88312
|
-
const projectRoot = config.userConfigPath &&
|
87953
|
+
const projectRoot = config.userConfigPath && import_node_path32.default.dirname(config.userConfigPath);
|
88313
87954
|
if (!config.configPath) {
|
88314
87955
|
if (args.script) {
|
88315
87956
|
try {
|
@@ -89433,6 +89074,446 @@ var init_update = __esm({
|
|
89433
89074
|
}
|
89434
89075
|
});
|
89435
89076
|
|
89077
|
+
// src/utils/create-batches.ts
|
89078
|
+
function* createBatches(array, size) {
|
89079
|
+
for (let i5 = 0; i5 < array.length; i5 += size) {
|
89080
|
+
yield array.slice(i5, i5 + size);
|
89081
|
+
}
|
89082
|
+
}
|
89083
|
+
var init_create_batches = __esm({
|
89084
|
+
"src/utils/create-batches.ts"() {
|
89085
|
+
init_import_meta_url();
|
89086
|
+
__name(createBatches, "createBatches");
|
89087
|
+
}
|
89088
|
+
});
|
89089
|
+
|
89090
|
+
// ../../node_modules/.pnpm/shell-quote@1.8.1/node_modules/shell-quote/quote.js
|
89091
|
+
var require_quote = __commonJS({
|
89092
|
+
"../../node_modules/.pnpm/shell-quote@1.8.1/node_modules/shell-quote/quote.js"(exports2, module3) {
|
89093
|
+
"use strict";
|
89094
|
+
init_import_meta_url();
|
89095
|
+
module3.exports = /* @__PURE__ */ __name(function quote2(xs) {
|
89096
|
+
return xs.map(function(s5) {
|
89097
|
+
if (s5 && typeof s5 === "object") {
|
89098
|
+
return s5.op.replace(/(.)/g, "\\$1");
|
89099
|
+
}
|
89100
|
+
if (/["\s]/.test(s5) && !/'/.test(s5)) {
|
89101
|
+
return "'" + s5.replace(/(['\\])/g, "\\$1") + "'";
|
89102
|
+
}
|
89103
|
+
if (/["'\s]/.test(s5)) {
|
89104
|
+
return '"' + s5.replace(/(["\\$`!])/g, "\\$1") + '"';
|
89105
|
+
}
|
89106
|
+
return String(s5).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g, "$1\\$2");
|
89107
|
+
}).join(" ");
|
89108
|
+
}, "quote");
|
89109
|
+
}
|
89110
|
+
});
|
89111
|
+
|
89112
|
+
// ../../node_modules/.pnpm/shell-quote@1.8.1/node_modules/shell-quote/parse.js
|
89113
|
+
var require_parse4 = __commonJS({
|
89114
|
+
"../../node_modules/.pnpm/shell-quote@1.8.1/node_modules/shell-quote/parse.js"(exports2, module3) {
|
89115
|
+
"use strict";
|
89116
|
+
init_import_meta_url();
|
89117
|
+
var CONTROL = "(?:" + [
|
89118
|
+
"\\|\\|",
|
89119
|
+
"\\&\\&",
|
89120
|
+
";;",
|
89121
|
+
"\\|\\&",
|
89122
|
+
"\\<\\(",
|
89123
|
+
"\\<\\<\\<",
|
89124
|
+
">>",
|
89125
|
+
">\\&",
|
89126
|
+
"<\\&",
|
89127
|
+
"[&;()|<>]"
|
89128
|
+
].join("|") + ")";
|
89129
|
+
var controlRE = new RegExp("^" + CONTROL + "$");
|
89130
|
+
var META = "|&;()<> \\t";
|
89131
|
+
var SINGLE_QUOTE = '"((\\\\"|[^"])*?)"';
|
89132
|
+
var DOUBLE_QUOTE = "'((\\\\'|[^'])*?)'";
|
89133
|
+
var hash = /^#$/;
|
89134
|
+
var SQ = "'";
|
89135
|
+
var DQ = '"';
|
89136
|
+
var DS = "$";
|
89137
|
+
var TOKEN = "";
|
89138
|
+
var mult = 4294967296;
|
89139
|
+
for (i5 = 0; i5 < 4; i5++) {
|
89140
|
+
TOKEN += (mult * Math.random()).toString(16);
|
89141
|
+
}
|
89142
|
+
var i5;
|
89143
|
+
var startsWithToken = new RegExp("^" + TOKEN);
|
89144
|
+
function matchAll(s5, r7) {
|
89145
|
+
var origIndex = r7.lastIndex;
|
89146
|
+
var matches = [];
|
89147
|
+
var matchObj;
|
89148
|
+
while (matchObj = r7.exec(s5)) {
|
89149
|
+
matches.push(matchObj);
|
89150
|
+
if (r7.lastIndex === matchObj.index) {
|
89151
|
+
r7.lastIndex += 1;
|
89152
|
+
}
|
89153
|
+
}
|
89154
|
+
r7.lastIndex = origIndex;
|
89155
|
+
return matches;
|
89156
|
+
}
|
89157
|
+
__name(matchAll, "matchAll");
|
89158
|
+
function getVar(env6, pre, key) {
|
89159
|
+
var r7 = typeof env6 === "function" ? env6(key) : env6[key];
|
89160
|
+
if (typeof r7 === "undefined" && key != "") {
|
89161
|
+
r7 = "";
|
89162
|
+
} else if (typeof r7 === "undefined") {
|
89163
|
+
r7 = "$";
|
89164
|
+
}
|
89165
|
+
if (typeof r7 === "object") {
|
89166
|
+
return pre + TOKEN + JSON.stringify(r7) + TOKEN;
|
89167
|
+
}
|
89168
|
+
return pre + r7;
|
89169
|
+
}
|
89170
|
+
__name(getVar, "getVar");
|
89171
|
+
function parseInternal(string, env6, opts) {
|
89172
|
+
if (!opts) {
|
89173
|
+
opts = {};
|
89174
|
+
}
|
89175
|
+
var BS = opts.escape || "\\";
|
89176
|
+
var BAREWORD = "(\\" + BS + `['"` + META + `]|[^\\s'"` + META + "])+";
|
89177
|
+
var chunker = new RegExp([
|
89178
|
+
"(" + CONTROL + ")",
|
89179
|
+
// control chars
|
89180
|
+
"(" + BAREWORD + "|" + SINGLE_QUOTE + "|" + DOUBLE_QUOTE + ")+"
|
89181
|
+
].join("|"), "g");
|
89182
|
+
var matches = matchAll(string, chunker);
|
89183
|
+
if (matches.length === 0) {
|
89184
|
+
return [];
|
89185
|
+
}
|
89186
|
+
if (!env6) {
|
89187
|
+
env6 = {};
|
89188
|
+
}
|
89189
|
+
var commented = false;
|
89190
|
+
return matches.map(function(match2) {
|
89191
|
+
var s5 = match2[0];
|
89192
|
+
if (!s5 || commented) {
|
89193
|
+
return void 0;
|
89194
|
+
}
|
89195
|
+
if (controlRE.test(s5)) {
|
89196
|
+
return { op: s5 };
|
89197
|
+
}
|
89198
|
+
var quote2 = false;
|
89199
|
+
var esc = false;
|
89200
|
+
var out = "";
|
89201
|
+
var isGlob = false;
|
89202
|
+
var i6;
|
89203
|
+
function parseEnvVar() {
|
89204
|
+
i6 += 1;
|
89205
|
+
var varend;
|
89206
|
+
var varname;
|
89207
|
+
var char = s5.charAt(i6);
|
89208
|
+
if (char === "{") {
|
89209
|
+
i6 += 1;
|
89210
|
+
if (s5.charAt(i6) === "}") {
|
89211
|
+
throw new Error("Bad substitution: " + s5.slice(i6 - 2, i6 + 1));
|
89212
|
+
}
|
89213
|
+
varend = s5.indexOf("}", i6);
|
89214
|
+
if (varend < 0) {
|
89215
|
+
throw new Error("Bad substitution: " + s5.slice(i6));
|
89216
|
+
}
|
89217
|
+
varname = s5.slice(i6, varend);
|
89218
|
+
i6 = varend;
|
89219
|
+
} else if (/[*@#?$!_-]/.test(char)) {
|
89220
|
+
varname = char;
|
89221
|
+
i6 += 1;
|
89222
|
+
} else {
|
89223
|
+
var slicedFromI = s5.slice(i6);
|
89224
|
+
varend = slicedFromI.match(/[^\w\d_]/);
|
89225
|
+
if (!varend) {
|
89226
|
+
varname = slicedFromI;
|
89227
|
+
i6 = s5.length;
|
89228
|
+
} else {
|
89229
|
+
varname = slicedFromI.slice(0, varend.index);
|
89230
|
+
i6 += varend.index - 1;
|
89231
|
+
}
|
89232
|
+
}
|
89233
|
+
return getVar(env6, "", varname);
|
89234
|
+
}
|
89235
|
+
__name(parseEnvVar, "parseEnvVar");
|
89236
|
+
for (i6 = 0; i6 < s5.length; i6++) {
|
89237
|
+
var c6 = s5.charAt(i6);
|
89238
|
+
isGlob = isGlob || !quote2 && (c6 === "*" || c6 === "?");
|
89239
|
+
if (esc) {
|
89240
|
+
out += c6;
|
89241
|
+
esc = false;
|
89242
|
+
} else if (quote2) {
|
89243
|
+
if (c6 === quote2) {
|
89244
|
+
quote2 = false;
|
89245
|
+
} else if (quote2 == SQ) {
|
89246
|
+
out += c6;
|
89247
|
+
} else {
|
89248
|
+
if (c6 === BS) {
|
89249
|
+
i6 += 1;
|
89250
|
+
c6 = s5.charAt(i6);
|
89251
|
+
if (c6 === DQ || c6 === BS || c6 === DS) {
|
89252
|
+
out += c6;
|
89253
|
+
} else {
|
89254
|
+
out += BS + c6;
|
89255
|
+
}
|
89256
|
+
} else if (c6 === DS) {
|
89257
|
+
out += parseEnvVar();
|
89258
|
+
} else {
|
89259
|
+
out += c6;
|
89260
|
+
}
|
89261
|
+
}
|
89262
|
+
} else if (c6 === DQ || c6 === SQ) {
|
89263
|
+
quote2 = c6;
|
89264
|
+
} else if (controlRE.test(c6)) {
|
89265
|
+
return { op: s5 };
|
89266
|
+
} else if (hash.test(c6)) {
|
89267
|
+
commented = true;
|
89268
|
+
var commentObj = { comment: string.slice(match2.index + i6 + 1) };
|
89269
|
+
if (out.length) {
|
89270
|
+
return [out, commentObj];
|
89271
|
+
}
|
89272
|
+
return [commentObj];
|
89273
|
+
} else if (c6 === BS) {
|
89274
|
+
esc = true;
|
89275
|
+
} else if (c6 === DS) {
|
89276
|
+
out += parseEnvVar();
|
89277
|
+
} else {
|
89278
|
+
out += c6;
|
89279
|
+
}
|
89280
|
+
}
|
89281
|
+
if (isGlob) {
|
89282
|
+
return { op: "glob", pattern: out };
|
89283
|
+
}
|
89284
|
+
return out;
|
89285
|
+
}).reduce(function(prev, arg) {
|
89286
|
+
return typeof arg === "undefined" ? prev : prev.concat(arg);
|
89287
|
+
}, []);
|
89288
|
+
}
|
89289
|
+
__name(parseInternal, "parseInternal");
|
89290
|
+
module3.exports = /* @__PURE__ */ __name(function parse7(s5, env6, opts) {
|
89291
|
+
var mapped = parseInternal(s5, env6, opts);
|
89292
|
+
if (typeof env6 !== "function") {
|
89293
|
+
return mapped;
|
89294
|
+
}
|
89295
|
+
return mapped.reduce(function(acc, s6) {
|
89296
|
+
if (typeof s6 === "object") {
|
89297
|
+
return acc.concat(s6);
|
89298
|
+
}
|
89299
|
+
var xs = s6.split(RegExp("(" + TOKEN + ".*?" + TOKEN + ")", "g"));
|
89300
|
+
if (xs.length === 1) {
|
89301
|
+
return acc.concat(xs[0]);
|
89302
|
+
}
|
89303
|
+
return acc.concat(xs.filter(Boolean).map(function(x6) {
|
89304
|
+
if (startsWithToken.test(x6)) {
|
89305
|
+
return JSON.parse(x6.split(TOKEN)[1]);
|
89306
|
+
}
|
89307
|
+
return x6;
|
89308
|
+
}));
|
89309
|
+
}, []);
|
89310
|
+
}, "parse");
|
89311
|
+
}
|
89312
|
+
});
|
89313
|
+
|
89314
|
+
// ../../node_modules/.pnpm/shell-quote@1.8.1/node_modules/shell-quote/index.js
|
89315
|
+
var require_shell_quote = __commonJS({
|
89316
|
+
"../../node_modules/.pnpm/shell-quote@1.8.1/node_modules/shell-quote/index.js"(exports2) {
|
89317
|
+
"use strict";
|
89318
|
+
init_import_meta_url();
|
89319
|
+
exports2.quote = require_quote();
|
89320
|
+
exports2.parse = require_parse4();
|
89321
|
+
}
|
89322
|
+
});
|
89323
|
+
|
89324
|
+
// src/utils/shell-quote.ts
|
89325
|
+
function parse4(cmd, env6) {
|
89326
|
+
if (process.platform === "win32") {
|
89327
|
+
cmd = cmd.replaceAll("\\", "\\\\");
|
89328
|
+
}
|
89329
|
+
const entries = import_shell_quote.default.parse(cmd, env6);
|
89330
|
+
const argv = [];
|
89331
|
+
for (const entry of entries) {
|
89332
|
+
if (typeof entry === "string") {
|
89333
|
+
argv.push(entry);
|
89334
|
+
continue;
|
89335
|
+
}
|
89336
|
+
if ("comment" in entry) {
|
89337
|
+
continue;
|
89338
|
+
}
|
89339
|
+
if (entry.op === "glob") {
|
89340
|
+
argv.push(entry.pattern);
|
89341
|
+
continue;
|
89342
|
+
}
|
89343
|
+
throw new Error(
|
89344
|
+
`Only simple commands are supported, please don't use the "${entry.op}" operator in "${cmd}".`
|
89345
|
+
);
|
89346
|
+
}
|
89347
|
+
return argv;
|
89348
|
+
}
|
89349
|
+
var import_shell_quote, quote;
|
89350
|
+
var init_shell_quote = __esm({
|
89351
|
+
"src/utils/shell-quote.ts"() {
|
89352
|
+
init_import_meta_url();
|
89353
|
+
import_shell_quote = __toESM(require_shell_quote());
|
89354
|
+
quote = /* @__PURE__ */ __name(function(args) {
|
89355
|
+
const stringArgs = args.map((arg) => String(arg));
|
89356
|
+
return import_shell_quote.default.quote(stringArgs);
|
89357
|
+
}, "quote");
|
89358
|
+
__name(parse4, "parse");
|
89359
|
+
}
|
89360
|
+
});
|
89361
|
+
|
89362
|
+
// src/init.ts
|
89363
|
+
function isNpm(packageManager) {
|
89364
|
+
return packageManager.type === "npm";
|
89365
|
+
}
|
89366
|
+
async function downloadWorker(accountId, workerName) {
|
89367
|
+
const serviceMetadata = await fetchResult(
|
89368
|
+
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
89369
|
+
`/accounts/${accountId}/workers/services/${workerName}`
|
89370
|
+
);
|
89371
|
+
const defaultEnvironment = serviceMetadata.default_environment.environment;
|
89372
|
+
const { entrypoint, modules } = await fetchWorkerDefinitionFromDash(
|
89373
|
+
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
89374
|
+
`/accounts/${accountId}/workers/services/${workerName}/environments/${defaultEnvironment}/content/v2`
|
89375
|
+
);
|
89376
|
+
const config = await downloadWorkerConfig(
|
89377
|
+
workerName,
|
89378
|
+
defaultEnvironment,
|
89379
|
+
entrypoint,
|
89380
|
+
accountId
|
89381
|
+
);
|
89382
|
+
return {
|
89383
|
+
modules,
|
89384
|
+
config
|
89385
|
+
};
|
89386
|
+
}
|
89387
|
+
var import_promises13, import_node_path33, import_toml5, init;
|
89388
|
+
var init_init = __esm({
|
89389
|
+
"src/init.ts"() {
|
89390
|
+
init_import_meta_url();
|
89391
|
+
import_promises13 = require("fs/promises");
|
89392
|
+
import_node_path33 = __toESM(require("path"));
|
89393
|
+
import_toml5 = __toESM(require_toml());
|
89394
|
+
init_execa();
|
89395
|
+
init_cfetch();
|
89396
|
+
init_internal();
|
89397
|
+
init_create_command();
|
89398
|
+
init_misc_variables();
|
89399
|
+
init_errors();
|
89400
|
+
init_logger();
|
89401
|
+
init_metrics_config();
|
89402
|
+
init_package_manager();
|
89403
|
+
init_user2();
|
89404
|
+
init_create_batches();
|
89405
|
+
init_download_worker_config();
|
89406
|
+
init_shell_quote();
|
89407
|
+
init = createCommand({
|
89408
|
+
metadata: {
|
89409
|
+
description: "\u{1F4E5} Initialize a basic Worker",
|
89410
|
+
owner: "Workers: Authoring and Testing",
|
89411
|
+
status: "stable"
|
89412
|
+
},
|
89413
|
+
args: {
|
89414
|
+
name: {
|
89415
|
+
describe: "The name of your worker",
|
89416
|
+
type: "string"
|
89417
|
+
},
|
89418
|
+
yes: {
|
89419
|
+
describe: 'Answer "yes" to any prompts for new projects',
|
89420
|
+
type: "boolean",
|
89421
|
+
alias: "y"
|
89422
|
+
},
|
89423
|
+
"from-dash": {
|
89424
|
+
describe: "The name of the Worker you wish to download from the Cloudflare dashboard for local development.",
|
89425
|
+
type: "string",
|
89426
|
+
requiresArg: true
|
89427
|
+
},
|
89428
|
+
"delegate-c3": {
|
89429
|
+
describe: "Delegate to Create Cloudflare CLI (C3)",
|
89430
|
+
type: "boolean",
|
89431
|
+
hidden: true,
|
89432
|
+
default: true,
|
89433
|
+
alias: "c3"
|
89434
|
+
}
|
89435
|
+
},
|
89436
|
+
behaviour: {
|
89437
|
+
provideConfig: false
|
89438
|
+
},
|
89439
|
+
positionalArgs: ["name"],
|
89440
|
+
async handler(args) {
|
89441
|
+
const yesFlag = args.yes ?? false;
|
89442
|
+
const packageManager = await getPackageManager();
|
89443
|
+
const name2 = args.fromDash ?? args.name;
|
89444
|
+
const c3Arguments = [
|
89445
|
+
...parse4(getC3CommandFromEnv()),
|
89446
|
+
...name2 ? [name2] : [],
|
89447
|
+
...yesFlag && isNpm(packageManager) ? ["-y"] : [],
|
89448
|
+
// --yes arg for npx
|
89449
|
+
...isNpm(packageManager) ? ["--"] : [],
|
89450
|
+
...args.fromDash ? ["--existing-script", args.fromDash] : [],
|
89451
|
+
...yesFlag ? ["--wrangler-defaults"] : []
|
89452
|
+
];
|
89453
|
+
const replacementC3Command = `\`${packageManager.type} ${c3Arguments.join(
|
89454
|
+
" "
|
89455
|
+
)}\``;
|
89456
|
+
if (args.fromDash && !args.delegateC3) {
|
89457
|
+
const accountId = await requireAuth({});
|
89458
|
+
try {
|
89459
|
+
await fetchResult(
|
89460
|
+
// `wrangler init` is not run from within a Workers project, so there will be no config file to define the compliance region.
|
89461
|
+
COMPLIANCE_REGION_CONFIG_UNKNOWN,
|
89462
|
+
`/accounts/${accountId}/workers/services/${args.fromDash}`
|
89463
|
+
);
|
89464
|
+
} catch (err) {
|
89465
|
+
if (err.code === 10090) {
|
89466
|
+
throw new UserError(
|
89467
|
+
"wrangler couldn't find a Worker with that name in your account.\nRun `wrangler whoami` to confirm you're logged into the correct account.",
|
89468
|
+
{
|
89469
|
+
telemetryMessage: true
|
89470
|
+
}
|
89471
|
+
);
|
89472
|
+
}
|
89473
|
+
throw err;
|
89474
|
+
}
|
89475
|
+
const creationDir = import_node_path33.default.join(process.cwd(), args.fromDash);
|
89476
|
+
await (0, import_promises13.mkdir)(creationDir, { recursive: true });
|
89477
|
+
const { modules, config } = await downloadWorker(
|
89478
|
+
accountId,
|
89479
|
+
args.fromDash
|
89480
|
+
);
|
89481
|
+
await (0, import_promises13.mkdir)(import_node_path33.default.join(creationDir, "./src"), {
|
89482
|
+
recursive: true
|
89483
|
+
});
|
89484
|
+
config.main = `src/${config.main}`;
|
89485
|
+
config.name = args.fromDash;
|
89486
|
+
for (const files of createBatches(modules, 10)) {
|
89487
|
+
await Promise.all(
|
89488
|
+
files.map(async (file) => {
|
89489
|
+
const filepath = import_node_path33.default.join(creationDir, `./src/${file.name}`);
|
89490
|
+
const directory = (0, import_node_path33.dirname)(filepath);
|
89491
|
+
await (0, import_promises13.mkdir)(directory, { recursive: true });
|
89492
|
+
await (0, import_promises13.writeFile)(filepath, file.stream());
|
89493
|
+
})
|
89494
|
+
);
|
89495
|
+
}
|
89496
|
+
await (0, import_promises13.writeFile)(
|
89497
|
+
import_node_path33.default.join(creationDir, "wrangler.toml"),
|
89498
|
+
import_toml5.default.stringify(config)
|
89499
|
+
);
|
89500
|
+
} else {
|
89501
|
+
logger.log(`\u{1F300} Running ${replacementC3Command}...`);
|
89502
|
+
const metricsConfig = readMetricsConfig();
|
89503
|
+
await execa(packageManager.type, c3Arguments, {
|
89504
|
+
stdio: "inherit",
|
89505
|
+
...metricsConfig.permission?.enabled === false && {
|
89506
|
+
env: { CREATE_CLOUDFLARE_TELEMETRY_DISABLED: "1" }
|
89507
|
+
}
|
89508
|
+
});
|
89509
|
+
}
|
89510
|
+
}
|
89511
|
+
});
|
89512
|
+
__name(isNpm, "isNpm");
|
89513
|
+
__name(downloadWorker, "downloadWorker");
|
89514
|
+
}
|
89515
|
+
});
|
89516
|
+
|
89436
89517
|
// src/kv/index.ts
|
89437
89518
|
var import_node_assert20, import_node_buffer4, import_consumers, import_node_string_decoder, kvNamespace, kvNamespaceNamespace, kvKeyNamespace, kvBulkNamespace, kvNamespaceCreateCommand, kvNamespaceListCommand, kvNamespaceDeleteCommand, kvNamespaceRenameCommand, kvKeyPutCommand, kvKeyListCommand, kvKeyGetCommand, kvKeyDeleteCommand, kvBulkGetCommand, kvBulkPutCommand, kvBulkDeleteCommand;
|
89438
89519
|
var init_kv = __esm({
|
@@ -151005,7 +151086,9 @@ var init_listVectors = __esm({
|
|
151005
151086
|
},
|
151006
151087
|
positionalArgs: ["name"],
|
151007
151088
|
async handler(args, { config }) {
|
151008
|
-
|
151089
|
+
if (!args.json) {
|
151090
|
+
logger.log(`\u{1F4CB} Listing vectors in index '${args.name}'...`);
|
151091
|
+
}
|
151009
151092
|
const options = {};
|
151010
151093
|
if (args.count !== void 0) {
|
151011
151094
|
options.count = args.count;
|
@@ -153533,6 +153616,7 @@ var init_upload2 = __esm({
|
|
153533
153616
|
owner: "Workers: Authoring and Testing",
|
153534
153617
|
status: "stable"
|
153535
153618
|
},
|
153619
|
+
positionalArgs: ["script"],
|
153536
153620
|
args: {
|
153537
153621
|
script: {
|
153538
153622
|
describe: "The path to an entry point for your Worker",
|
@@ -153540,17 +153624,32 @@ var init_upload2 = __esm({
|
|
153540
153624
|
requiresArg: true
|
153541
153625
|
},
|
153542
153626
|
name: {
|
153543
|
-
describe: "Name of the
|
153627
|
+
describe: "Name of the Worker",
|
153628
|
+
type: "string",
|
153629
|
+
requiresArg: true
|
153630
|
+
},
|
153631
|
+
tag: {
|
153632
|
+
describe: "A tag for this Worker Gradual Rollouts Version",
|
153633
|
+
type: "string",
|
153634
|
+
requiresArg: true
|
153635
|
+
},
|
153636
|
+
message: {
|
153637
|
+
describe: "A descriptive message for this Worker Gradual Rollouts Version",
|
153638
|
+
type: "string",
|
153639
|
+
requiresArg: true
|
153640
|
+
},
|
153641
|
+
"preview-alias": {
|
153642
|
+
describe: "Name of an alias for this Worker version",
|
153544
153643
|
type: "string",
|
153545
153644
|
requiresArg: true
|
153546
153645
|
},
|
153547
153646
|
bundle: {
|
153548
|
-
describe: "Run
|
153647
|
+
describe: "Run Wrangler's compilation step before publishing",
|
153549
153648
|
type: "boolean",
|
153550
153649
|
hidden: true
|
153551
153650
|
},
|
153552
153651
|
"no-bundle": {
|
153553
|
-
describe: "Skip internal build steps and directly
|
153652
|
+
describe: "Skip internal build steps and directly upload Worker",
|
153554
153653
|
type: "boolean",
|
153555
153654
|
default: false
|
153556
153655
|
},
|
@@ -153657,24 +153756,9 @@ var init_upload2 = __esm({
|
|
153657
153756
|
deprecated: true
|
153658
153757
|
},
|
153659
153758
|
"dry-run": {
|
153660
|
-
describe: "
|
153759
|
+
describe: "Compile a project without actually uploading the version.",
|
153661
153760
|
type: "boolean"
|
153662
153761
|
},
|
153663
|
-
tag: {
|
153664
|
-
describe: "A tag for this Worker Gradual Rollouts Version",
|
153665
|
-
type: "string",
|
153666
|
-
requiresArg: true
|
153667
|
-
},
|
153668
|
-
message: {
|
153669
|
-
describe: "A descriptive message for this Worker Gradual Rollouts Version",
|
153670
|
-
type: "string",
|
153671
|
-
requiresArg: true
|
153672
|
-
},
|
153673
|
-
"preview-alias": {
|
153674
|
-
describe: "Name of an alias for this Worker version",
|
153675
|
-
type: "string",
|
153676
|
-
requiresArg: true
|
153677
|
-
},
|
153678
153762
|
"experimental-auto-create": {
|
153679
153763
|
describe: "Automatically provision draft bindings with new resources",
|
153680
153764
|
type: "boolean",
|
@@ -159421,13 +159505,16 @@ function configDiffOnlyHasAdditionsIfAny(diff) {
|
|
159421
159505
|
});
|
159422
159506
|
}
|
159423
159507
|
function normalizeLocalResolvedConfigAsRemote(localResolvedConfig) {
|
159508
|
+
const subdomainValues = getSubdomainValues(
|
159509
|
+
localResolvedConfig.workers_dev,
|
159510
|
+
localResolvedConfig.preview_urls,
|
159511
|
+
localResolvedConfig.routes ?? []
|
159512
|
+
);
|
159424
159513
|
const normalizedConfig = {
|
159425
159514
|
...localResolvedConfig,
|
159426
|
-
|
159427
|
-
|
159428
|
-
|
159429
|
-
localResolvedConfig.routes ?? []
|
159430
|
-
)
|
159515
|
+
workers_dev: subdomainValues.workers_dev,
|
159516
|
+
preview_urls: subdomainValues.preview_urls,
|
159517
|
+
observability: normalizeObservability(localResolvedConfig.observability)
|
159431
159518
|
};
|
159432
159519
|
return normalizedConfig;
|
159433
159520
|
}
|
@@ -159527,8 +159614,8 @@ var init_config_diffs = __esm({
|
|
159527
159614
|
"src/deploy/config-diffs.ts"() {
|
159528
159615
|
init_import_meta_url();
|
159529
159616
|
init_colors();
|
159530
|
-
init_diff();
|
159531
159617
|
init_deploy3();
|
159618
|
+
init_diff();
|
159532
159619
|
__name(getRemoteConfigDiff, "getRemoteConfigDiff");
|
159533
159620
|
__name(configDiffOnlyHasAdditionsIfAny, "configDiffOnlyHasAdditionsIfAny");
|
159534
159621
|
__name(normalizeLocalResolvedConfigAsRemote, "normalizeLocalResolvedConfigAsRemote");
|
@@ -159660,10 +159747,10 @@ async function deploy(props) {
|
|
159660
159747
|
let configDiff;
|
159661
159748
|
if (getFlag("DEPLOY_REMOTE_DIFF_CHECK")) {
|
159662
159749
|
const remoteWorkerConfig = await downloadWorkerConfig(
|
159663
|
-
accountId,
|
159664
159750
|
name2,
|
159751
|
+
serviceMetaData.default_environment.environment,
|
159665
159752
|
entry.file,
|
159666
|
-
|
159753
|
+
accountId
|
159667
159754
|
);
|
159668
159755
|
configDiff = getRemoteConfigDiff(remoteWorkerConfig, {
|
159669
159756
|
...config,
|
@@ -160450,7 +160537,6 @@ var init_deploy8 = __esm({
|
|
160450
160537
|
init_misc_variables();
|
160451
160538
|
init_errors();
|
160452
160539
|
init_experimental_flags();
|
160453
|
-
init_init();
|
160454
160540
|
init_logger();
|
160455
160541
|
init_metrics();
|
160456
160542
|
init_navigator_user_agent();
|
@@ -160461,6 +160547,7 @@ var init_deploy8 = __esm({
|
|
160461
160547
|
init_sourcemap();
|
160462
160548
|
init_deploy3();
|
160463
160549
|
init_compatibility_date();
|
160550
|
+
init_download_worker_config();
|
160464
160551
|
init_friendly_validator_errors();
|
160465
160552
|
init_print_bindings();
|
160466
160553
|
init_retry();
|
@@ -160543,7 +160630,7 @@ function logAssetUpload(line, diffCount) {
|
|
160543
160630
|
const msg = " (truncating changed assets log, set `WRANGLER_LOG=debug` environment variable to see full diff)";
|
160544
160631
|
logger.info(source_default.dim(msg));
|
160545
160632
|
}
|
160546
|
-
return diffCount
|
160633
|
+
return ++diffCount;
|
160547
160634
|
}
|
160548
160635
|
function logAssetsUploadStatus(numberFilesToUpload, uploadedAssetsCount, uploadedAssetFiles) {
|
160549
160636
|
logger.info(
|
@@ -160868,7 +160955,6 @@ Assets already uploaded have been saved, so the next attempt will automatically
|
|
160868
160955
|
const files = await (0, import_promises35.readdir)(dir, { recursive: true });
|
160869
160956
|
logReadFilesFromDirectory(dir, files);
|
160870
160957
|
const manifest = {};
|
160871
|
-
let counter = 0;
|
160872
160958
|
const { assetsIgnoreFunction, assetsIgnoreFilePresent } = await createAssetsIgnoreFunction(dir);
|
160873
160959
|
await Promise.all(
|
160874
160960
|
files.map(async (relativeFilepath) => {
|
@@ -160885,14 +160971,6 @@ Assets already uploaded have been saved, so the next attempt will automatically
|
|
160885
160971
|
relativeFilepath,
|
160886
160972
|
assetsIgnoreFilePresent
|
160887
160973
|
);
|
160888
|
-
if (counter >= MAX_ASSET_COUNT2) {
|
160889
|
-
throw new UserError(
|
160890
|
-
`Maximum number of assets exceeded.
|
160891
|
-
Cloudflare Workers supports up to ${MAX_ASSET_COUNT2.toLocaleString()} assets in a version. We found ${counter.toLocaleString()} files in the specified assets directory "${dir}".
|
160892
|
-
Ensure your assets directory contains a maximum of ${MAX_ASSET_COUNT2.toLocaleString()} files, and that you have specified your assets directory correctly.`,
|
160893
|
-
{ telemetryMessage: "Maximum number of assets exceeded" }
|
160894
|
-
);
|
160895
|
-
}
|
160896
160974
|
if (filestat.size > MAX_ASSET_SIZE2) {
|
160897
160975
|
throw new UserError(
|
160898
160976
|
`Asset too large.
|
@@ -160915,7 +160993,6 @@ Ensure all assets in your assets directory "${dir}" conform with the Workers max
|
|
160915
160993
|
hash: hashFile(filepath),
|
160916
160994
|
size: filestat.size
|
160917
160995
|
};
|
160918
|
-
counter++;
|
160919
160996
|
}
|
160920
160997
|
})
|
160921
160998
|
);
|
@@ -180126,6 +180203,7 @@ var init_ProxyController = __esm({
|
|
180126
180203
|
init_https_options();
|
180127
180204
|
init_logger();
|
180128
180205
|
init_sourcemap();
|
180206
|
+
init_assert_never();
|
180129
180207
|
init_BaseController();
|
180130
180208
|
init_events();
|
180131
180209
|
init_utils2();
|