wrangler 4.28.0 → 4.28.1
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/package.json +4 -4
- package/wrangler-dist/cli.d.ts +32 -10
- package/wrangler-dist/cli.js +326 -195
- package/wrangler-dist/metafile-cjs.json +1 -1
package/wrangler-dist/cli.js
CHANGED
@@ -33117,6 +33117,38 @@ var require_signal_exit = __commonJS({
|
|
33117
33117
|
}
|
33118
33118
|
});
|
33119
33119
|
|
33120
|
+
// ../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js
|
33121
|
+
function ansiRegex({ onlyFirst = false } = {}) {
|
33122
|
+
const pattern = [
|
33123
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
33124
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
33125
|
+
].join("|");
|
33126
|
+
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
33127
|
+
}
|
33128
|
+
var init_ansi_regex = __esm({
|
33129
|
+
"../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js"() {
|
33130
|
+
init_import_meta_url();
|
33131
|
+
__name(ansiRegex, "ansiRegex");
|
33132
|
+
}
|
33133
|
+
});
|
33134
|
+
|
33135
|
+
// ../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js
|
33136
|
+
function stripAnsi2(string) {
|
33137
|
+
if (typeof string !== "string") {
|
33138
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
33139
|
+
}
|
33140
|
+
return string.replace(regex, "");
|
33141
|
+
}
|
33142
|
+
var regex;
|
33143
|
+
var init_strip_ansi = __esm({
|
33144
|
+
"../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js"() {
|
33145
|
+
init_import_meta_url();
|
33146
|
+
init_ansi_regex();
|
33147
|
+
regex = ansiRegex();
|
33148
|
+
__name(stripAnsi2, "stripAnsi");
|
33149
|
+
}
|
33150
|
+
});
|
33151
|
+
|
33120
33152
|
// src/utils/filesystem.ts
|
33121
33153
|
async function ensureDirectoryExists(filepath) {
|
33122
33154
|
const dirpath = import_path6.default.dirname(filepath);
|
@@ -33148,7 +33180,7 @@ function getDebugFilepath() {
|
|
33148
33180
|
async function appendToDebugLogFile(messageLevel, message) {
|
33149
33181
|
const entry = `
|
33150
33182
|
--- ${(/* @__PURE__ */ new Date()).toISOString()} ${messageLevel}
|
33151
|
-
${message}
|
33183
|
+
${stripAnsi2(message)}
|
33152
33184
|
---
|
33153
33185
|
`;
|
33154
33186
|
if (!hasLoggedLocation) {
|
@@ -33187,6 +33219,7 @@ var init_log_file = __esm({
|
|
33187
33219
|
import_node_path3 = __toESM(require("path"));
|
33188
33220
|
import_miniflare = require("miniflare");
|
33189
33221
|
import_signal_exit = __toESM(require_signal_exit());
|
33222
|
+
init_strip_ansi();
|
33190
33223
|
init_factory();
|
33191
33224
|
init_global_wrangler_config_path();
|
33192
33225
|
init_logger();
|
@@ -33752,7 +33785,7 @@ var name, version;
|
|
33752
33785
|
var init_package = __esm({
|
33753
33786
|
"package.json"() {
|
33754
33787
|
name = "wrangler";
|
33755
|
-
version = "4.28.
|
33788
|
+
version = "4.28.1";
|
33756
33789
|
}
|
33757
33790
|
});
|
33758
33791
|
|
@@ -35501,38 +35534,6 @@ var init_helpers = __esm({
|
|
35501
35534
|
}
|
35502
35535
|
});
|
35503
35536
|
|
35504
|
-
// ../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js
|
35505
|
-
function ansiRegex({ onlyFirst = false } = {}) {
|
35506
|
-
const pattern = [
|
35507
|
-
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
35508
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
35509
|
-
].join("|");
|
35510
|
-
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
35511
|
-
}
|
35512
|
-
var init_ansi_regex = __esm({
|
35513
|
-
"../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js"() {
|
35514
|
-
init_import_meta_url();
|
35515
|
-
__name(ansiRegex, "ansiRegex");
|
35516
|
-
}
|
35517
|
-
});
|
35518
|
-
|
35519
|
-
// ../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js
|
35520
|
-
function stripAnsi2(string) {
|
35521
|
-
if (typeof string !== "string") {
|
35522
|
-
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
35523
|
-
}
|
35524
|
-
return string.replace(regex, "");
|
35525
|
-
}
|
35526
|
-
var regex;
|
35527
|
-
var init_strip_ansi = __esm({
|
35528
|
-
"../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js"() {
|
35529
|
-
init_import_meta_url();
|
35530
|
-
init_ansi_regex();
|
35531
|
-
regex = ansiRegex();
|
35532
|
-
__name(stripAnsi2, "stripAnsi");
|
35533
|
-
}
|
35534
|
-
});
|
35535
|
-
|
35536
35537
|
// src/utils/print-bindings.ts
|
35537
35538
|
function printBindings(bindings, tailConsumers = [], context2 = {}) {
|
35538
35539
|
let hasConnectionStatus = false;
|
@@ -49451,14 +49452,14 @@ var init_user2 = __esm({
|
|
49451
49452
|
});
|
49452
49453
|
|
49453
49454
|
// src/cfetch/internal.ts
|
49454
|
-
async function performApiFetch(complianceConfig, resource, init3 = {}, queryParams, abortSignal) {
|
49455
|
+
async function performApiFetch(complianceConfig, resource, init3 = {}, queryParams, abortSignal, apiToken) {
|
49455
49456
|
const method = init3.method ?? "GET";
|
49456
49457
|
(0, import_node_assert3.default)(
|
49457
49458
|
resource.startsWith("/"),
|
49458
49459
|
`CF API fetch - resource path must start with a "/" but got "${resource}"`
|
49459
49460
|
);
|
49460
49461
|
await requireLoggedIn(complianceConfig);
|
49461
|
-
|
49462
|
+
apiToken ??= requireApiToken();
|
49462
49463
|
const headers = cloneHeaders(new import_undici3.Headers(init3.headers));
|
49463
49464
|
addAuthorizationHeaderIfUnspecified(headers, apiToken);
|
49464
49465
|
addUserAgent(headers);
|
@@ -49490,14 +49491,15 @@ async function performApiFetch(complianceConfig, resource, init3 = {}, queryPara
|
|
49490
49491
|
}
|
49491
49492
|
);
|
49492
49493
|
}
|
49493
|
-
async function fetchInternal(complianceConfig, resource, init3 = {}, queryParams, abortSignal) {
|
49494
|
+
async function fetchInternal(complianceConfig, resource, init3 = {}, queryParams, abortSignal, apiToken) {
|
49494
49495
|
const method = init3.method ?? "GET";
|
49495
49496
|
const response = await performApiFetch(
|
49496
49497
|
complianceConfig,
|
49497
49498
|
resource,
|
49498
49499
|
init3,
|
49499
49500
|
queryParams,
|
49500
|
-
abortSignal
|
49501
|
+
abortSignal,
|
49502
|
+
apiToken
|
49501
49503
|
);
|
49502
49504
|
const jsonText = await response.text();
|
49503
49505
|
logger.debug(
|
@@ -49668,13 +49670,14 @@ var init_internal = __esm({
|
|
49668
49670
|
});
|
49669
49671
|
|
49670
49672
|
// src/cfetch/index.ts
|
49671
|
-
async function fetchResult(complianceConfig, resource, init3 = {}, queryParams, abortSignal) {
|
49673
|
+
async function fetchResult(complianceConfig, resource, init3 = {}, queryParams, abortSignal, apiToken) {
|
49672
49674
|
const json = await fetchInternal(
|
49673
49675
|
complianceConfig,
|
49674
49676
|
resource,
|
49675
49677
|
init3,
|
49676
49678
|
queryParams,
|
49677
|
-
abortSignal
|
49679
|
+
abortSignal,
|
49680
|
+
apiToken
|
49678
49681
|
);
|
49679
49682
|
if (json.success) {
|
49680
49683
|
return json.result;
|
@@ -58912,11 +58915,11 @@ function buildMiniflareBindingOptions(config, remoteProxyConnectionString, remot
|
|
58912
58915
|
{
|
58913
58916
|
className,
|
58914
58917
|
useSQLite: classNameToUseSQLite.get(className),
|
58915
|
-
container: getImageNameFromDOClassName({
|
58918
|
+
container: config.containerDOClassNames?.size && config.enableContainers ? getImageNameFromDOClassName({
|
58916
58919
|
doClassName: className,
|
58917
58920
|
containerDOClassNames: config.containerDOClassNames,
|
58918
58921
|
containerBuildId: config.containerBuildId
|
58919
|
-
})
|
58922
|
+
}) : void 0
|
58920
58923
|
}
|
58921
58924
|
];
|
58922
58925
|
}),
|
@@ -59093,9 +59096,6 @@ async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticati
|
|
59093
59096
|
return { options, internalObjects, entrypointNames };
|
59094
59097
|
}
|
59095
59098
|
function getImageNameFromDOClassName(options) {
|
59096
|
-
if (!options.containerDOClassNames || !options.containerDOClassNames.size) {
|
59097
|
-
return void 0;
|
59098
|
-
}
|
59099
59099
|
(0, import_node_assert5.default)(
|
59100
59100
|
options.containerBuildId,
|
59101
59101
|
"Build ID should be set if containers are defined and enabled"
|
@@ -65731,6 +65731,199 @@ var init_dist2 = __esm({
|
|
65731
65731
|
}
|
65732
65732
|
});
|
65733
65733
|
|
65734
|
+
// src/cloudchamber/instance-type/instance-type.ts
|
65735
|
+
async function promptForInstanceType(allowSkipping) {
|
65736
|
+
let options = [
|
65737
|
+
{ label: "dev: 1/16 vCPU, 256 MiB memory, 2 GB disk", value: "dev" },
|
65738
|
+
{ label: "basic: 1/4 vCPU, 1 GiB memory, 4 GB disk", value: "basic" },
|
65739
|
+
{ label: "standard: 1/2 vCPU, 4 GiB memory, 4 GB disk", value: "standard" }
|
65740
|
+
];
|
65741
|
+
if (allowSkipping) {
|
65742
|
+
options = [{ label: "Do not set", value: "skip" }].concat(options);
|
65743
|
+
}
|
65744
|
+
const action = await inputPrompt({
|
65745
|
+
question: "Which instance type should we use for your container?",
|
65746
|
+
label: "",
|
65747
|
+
defaultValue: false,
|
65748
|
+
helpText: "",
|
65749
|
+
type: "select",
|
65750
|
+
options
|
65751
|
+
});
|
65752
|
+
switch (action) {
|
65753
|
+
case "dev":
|
65754
|
+
case "basic":
|
65755
|
+
case "standard":
|
65756
|
+
return action;
|
65757
|
+
default:
|
65758
|
+
return void 0;
|
65759
|
+
}
|
65760
|
+
}
|
65761
|
+
function checkInstanceType(args, config) {
|
65762
|
+
const instance_type = args.instanceType ?? config.instance_type;
|
65763
|
+
if (instance_type === void 0) {
|
65764
|
+
return;
|
65765
|
+
}
|
65766
|
+
if (args.memory !== void 0 || args.vcpu !== void 0) {
|
65767
|
+
throw new UserError(
|
65768
|
+
`Field "instance_type" is mutually exclusive with "memory" and "vcpu". These fields cannot be set together.`
|
65769
|
+
);
|
65770
|
+
}
|
65771
|
+
switch (instance_type) {
|
65772
|
+
case "dev":
|
65773
|
+
case "basic":
|
65774
|
+
case "standard":
|
65775
|
+
return instance_type;
|
65776
|
+
default:
|
65777
|
+
throw new UserError(
|
65778
|
+
`"instance_type" field value is expected to be one of "dev", "basic", or "standard", but got "${instance_type}"`
|
65779
|
+
);
|
65780
|
+
}
|
65781
|
+
}
|
65782
|
+
function getInstanceTypeUsage(instanceType) {
|
65783
|
+
return instanceTypes[instanceType];
|
65784
|
+
}
|
65785
|
+
function inferInstanceType(config) {
|
65786
|
+
for (const [instanceType, configuration] of Object.entries(instanceTypes)) {
|
65787
|
+
if (config.vcpu === configuration.vcpu && config.memory_mib === configuration.memory_mib && config.disk?.size_mb === configuration.disk_mb) {
|
65788
|
+
return instanceType;
|
65789
|
+
}
|
65790
|
+
}
|
65791
|
+
}
|
65792
|
+
function cleanForInstanceType(app) {
|
65793
|
+
if (!("configuration" in app)) {
|
65794
|
+
return app;
|
65795
|
+
}
|
65796
|
+
const instance_type = inferInstanceType(app.configuration);
|
65797
|
+
if (instance_type !== void 0) {
|
65798
|
+
app.configuration.instance_type = instance_type;
|
65799
|
+
}
|
65800
|
+
delete app.configuration.disk;
|
65801
|
+
delete app.configuration.memory;
|
65802
|
+
delete app.configuration.memory_mib;
|
65803
|
+
delete app.configuration.vcpu;
|
65804
|
+
return app;
|
65805
|
+
}
|
65806
|
+
var instanceTypes;
|
65807
|
+
var init_instance_type = __esm({
|
65808
|
+
"src/cloudchamber/instance-type/instance-type.ts"() {
|
65809
|
+
init_import_meta_url();
|
65810
|
+
init_interactive();
|
65811
|
+
init_errors();
|
65812
|
+
instanceTypes = {
|
65813
|
+
// dev is the default instance type when REQUIRE_INSTANCE_TYPE is set
|
65814
|
+
dev: {
|
65815
|
+
vcpu: 0.0625,
|
65816
|
+
memory_mib: 256,
|
65817
|
+
disk_mb: 2e3
|
65818
|
+
},
|
65819
|
+
basic: {
|
65820
|
+
vcpu: 0.25,
|
65821
|
+
memory_mib: 1024,
|
65822
|
+
disk_mb: 4e3
|
65823
|
+
},
|
65824
|
+
standard: {
|
65825
|
+
vcpu: 0.5,
|
65826
|
+
memory_mib: 4096,
|
65827
|
+
disk_mb: 4e3
|
65828
|
+
}
|
65829
|
+
};
|
65830
|
+
__name(promptForInstanceType, "promptForInstanceType");
|
65831
|
+
__name(checkInstanceType, "checkInstanceType");
|
65832
|
+
__name(getInstanceTypeUsage, "getInstanceTypeUsage");
|
65833
|
+
__name(inferInstanceType, "inferInstanceType");
|
65834
|
+
__name(cleanForInstanceType, "cleanForInstanceType");
|
65835
|
+
}
|
65836
|
+
});
|
65837
|
+
|
65838
|
+
// src/cloudchamber/limits.ts
|
65839
|
+
function configToUsage(containerConfig) {
|
65840
|
+
if ("instance_type" in containerConfig) {
|
65841
|
+
return getInstanceTypeUsage(containerConfig.instance_type);
|
65842
|
+
}
|
65843
|
+
return {
|
65844
|
+
vcpu: containerConfig.vcpu,
|
65845
|
+
memory_mib: containerConfig.memory_mib,
|
65846
|
+
disk_mb: containerConfig.disk_bytes / MB
|
65847
|
+
};
|
65848
|
+
}
|
65849
|
+
function accountToLimits(account) {
|
65850
|
+
return {
|
65851
|
+
vcpu: account.limits.vcpu_per_deployment,
|
65852
|
+
memory_mib: account.limits.memory_mib_per_deployment,
|
65853
|
+
disk_mb: account.limits.disk_mb_per_deployment
|
65854
|
+
};
|
65855
|
+
}
|
65856
|
+
async function ensureContainerLimits(options) {
|
65857
|
+
const limits = accountToLimits(options.account);
|
65858
|
+
if (!options.containerConfig) {
|
65859
|
+
await ensureImageFitsLimits({
|
65860
|
+
availableSizeInBytes: limits.disk_mb * MB,
|
65861
|
+
pathToDocker: options.pathToDocker,
|
65862
|
+
imageTag: options.imageTag
|
65863
|
+
});
|
65864
|
+
return;
|
65865
|
+
}
|
65866
|
+
const usage2 = configToUsage(options.containerConfig);
|
65867
|
+
const errors = [];
|
65868
|
+
if (usage2.vcpu > limits.vcpu) {
|
65869
|
+
errors.push(
|
65870
|
+
`Your container configuration uses ${usage2.vcpu} vCPU which exceeds the account limit of ${limits.vcpu} vCPU.`
|
65871
|
+
);
|
65872
|
+
}
|
65873
|
+
if (usage2.memory_mib > limits.memory_mib) {
|
65874
|
+
errors.push(
|
65875
|
+
`Your container configuration uses ${usage2.memory_mib} MiB of memory which exceeds the account limit of ${limits.memory_mib} MiB.`
|
65876
|
+
);
|
65877
|
+
}
|
65878
|
+
if (usage2.disk_mb > limits.disk_mb) {
|
65879
|
+
errors.push(
|
65880
|
+
`Your container configuration uses ${usage2.disk_mb} MB of disk which exceeds the account limit of ${limits.disk_mb} MB.`
|
65881
|
+
);
|
65882
|
+
}
|
65883
|
+
if (errors.length > 0) {
|
65884
|
+
throw new UserError(`Exceeded account limits: ${errors.join(" ")}`);
|
65885
|
+
}
|
65886
|
+
await ensureImageFitsLimits({
|
65887
|
+
availableSizeInBytes: usage2.disk_mb * MB,
|
65888
|
+
pathToDocker: options.pathToDocker,
|
65889
|
+
imageTag: options.imageTag
|
65890
|
+
});
|
65891
|
+
}
|
65892
|
+
async function ensureImageFitsLimits(options) {
|
65893
|
+
const inspectOutput = await dockerImageInspect(options.pathToDocker, {
|
65894
|
+
imageTag: options.imageTag,
|
65895
|
+
formatString: "{{ .Size }} {{ len .RootFS.Layers }}"
|
65896
|
+
});
|
65897
|
+
const [sizeStr, layerStr] = inspectOutput.split(" ");
|
65898
|
+
const size = parseInt(sizeStr, 10);
|
65899
|
+
const layers = parseInt(layerStr, 10);
|
65900
|
+
const requiredSizeInBytes = Math.ceil(size * 1.1 + layers * 16 * MiB);
|
65901
|
+
logger.debug(
|
65902
|
+
`Disk size limits when building container image: availableSize=${Math.ceil(options.availableSizeInBytes / MB)}MB, requiredSize=${Math.ceil(requiredSizeInBytes / MB)}MB`
|
65903
|
+
);
|
65904
|
+
if (options.availableSizeInBytes < requiredSizeInBytes) {
|
65905
|
+
throw new UserError(
|
65906
|
+
`Image too large: needs ${Math.ceil(requiredSizeInBytes / MB)}MB, but your app is limited to images with size ${options.availableSizeInBytes / MB}MB. Your need more disk for this image.`
|
65907
|
+
);
|
65908
|
+
}
|
65909
|
+
}
|
65910
|
+
var MB, MiB;
|
65911
|
+
var init_limits = __esm({
|
65912
|
+
"src/cloudchamber/limits.ts"() {
|
65913
|
+
init_import_meta_url();
|
65914
|
+
init_containers_shared();
|
65915
|
+
init_errors();
|
65916
|
+
init_logger();
|
65917
|
+
init_instance_type();
|
65918
|
+
MB = 1e3 * 1e3;
|
65919
|
+
MiB = 1024 * 1024;
|
65920
|
+
__name(configToUsage, "configToUsage");
|
65921
|
+
__name(accountToLimits, "accountToLimits");
|
65922
|
+
__name(ensureContainerLimits, "ensureContainerLimits");
|
65923
|
+
__name(ensureImageFitsLimits, "ensureImageFitsLimits");
|
65924
|
+
}
|
65925
|
+
});
|
65926
|
+
|
65734
65927
|
// src/cloudchamber/locations.ts
|
65735
65928
|
async function loadAccount() {
|
65736
65929
|
if (cachedAccount !== void 0) {
|
@@ -65804,7 +65997,7 @@ function pushYargs(yargs) {
|
|
65804
65997
|
demandOption: false
|
65805
65998
|
}).positional("TAG", { type: "string", demandOption: true });
|
65806
65999
|
}
|
65807
|
-
async function buildAndMaybePush(args, pathToDocker, push,
|
66000
|
+
async function buildAndMaybePush(args, pathToDocker, push, containerConfig) {
|
65808
66001
|
try {
|
65809
66002
|
const imageTag = `${getCloudflareContainerRegistry()}/${args.tag}`;
|
65810
66003
|
const { buildCmd, dockerfile } = await constructBuildCommand(
|
@@ -65822,22 +66015,18 @@ async function buildAndMaybePush(args, pathToDocker, push, configDiskInBytes) {
|
|
65822
66015
|
buildCmd,
|
65823
66016
|
dockerfile
|
65824
66017
|
}).ready;
|
65825
|
-
const
|
66018
|
+
const repoDigests = await dockerImageInspect(pathToDocker, {
|
65826
66019
|
imageTag,
|
65827
|
-
formatString: "{{
|
66020
|
+
formatString: "{{json .RepoDigests}}"
|
65828
66021
|
});
|
65829
|
-
const [sizeStr, layerStr, repoDigests] = inspectOutput.split(" ");
|
65830
66022
|
let pushed = false;
|
65831
66023
|
if (push) {
|
65832
66024
|
const account = await loadAccount();
|
65833
|
-
|
65834
|
-
|
65835
|
-
|
65836
|
-
const requiredSizeInBytes = Math.ceil(size * 1.1 + layers * 16 * MiB);
|
65837
|
-
await ensureDiskLimits({
|
65838
|
-
requiredSizeInBytes,
|
66025
|
+
await ensureContainerLimits({
|
66026
|
+
pathToDocker,
|
66027
|
+
imageTag,
|
65839
66028
|
account,
|
65840
|
-
|
66029
|
+
containerConfig
|
65841
66030
|
});
|
65842
66031
|
await dockerLoginManagedRegistry(pathToDocker);
|
65843
66032
|
try {
|
@@ -65922,8 +66111,8 @@ async function buildCommand(args) {
|
|
65922
66111
|
},
|
65923
66112
|
getDockerPath() ?? args.pathToDocker,
|
65924
66113
|
args.push,
|
65925
|
-
// this means we
|
65926
|
-
//
|
66114
|
+
// this means we aren't validating defined limits for a container when building an image
|
66115
|
+
// we will, however, still validate the image size against account level disk limits
|
65927
66116
|
void 0
|
65928
66117
|
);
|
65929
66118
|
}
|
@@ -65958,24 +66147,6 @@ async function checkImagePlatform(pathToDocker, imageTag, expectedPlatform = "li
|
|
65958
66147
|
);
|
65959
66148
|
}
|
65960
66149
|
}
|
65961
|
-
async function ensureDiskLimits(options) {
|
65962
|
-
const MB = 1e3 * 1e3;
|
65963
|
-
const accountDiskSizeInBytes = (options.account.limits.disk_mb_per_deployment ?? 2e3) * MB;
|
65964
|
-
if (options.configDiskInBytes && options.configDiskInBytes > accountDiskSizeInBytes) {
|
65965
|
-
throw new UserError(
|
65966
|
-
`Exceeded account limits: Your container is configured to use a disk size of ${Math.ceil(options.configDiskInBytes / MB)}MB. However, that exceeds the account limit of ${accountDiskSizeInBytes / MB}MB`
|
65967
|
-
);
|
65968
|
-
}
|
65969
|
-
const maxAllowedImageSizeBytes = options.configDiskInBytes ?? accountDiskSizeInBytes;
|
65970
|
-
logger.debug(
|
65971
|
-
`Disk size limits when building the container: appDiskSize: ${options.configDiskInBytes ? Math.ceil(options.configDiskInBytes / MB) : "n/a"}MB, accountDiskSize:${accountDiskSizeInBytes / MB}MB, maxAllowedImageSizeBytes=${maxAllowedImageSizeBytes}(${maxAllowedImageSizeBytes / MB}MB), requiredSize=${options.requiredSizeInBytes}(${Math.ceil(options.requiredSizeInBytes / MB)}MB)`
|
65972
|
-
);
|
65973
|
-
if (maxAllowedImageSizeBytes < options.requiredSizeInBytes) {
|
65974
|
-
throw new UserError(
|
65975
|
-
`Image too large: needs ${Math.ceil(options.requiredSizeInBytes / MB)}MB, but your app is limited to images with size ${maxAllowedImageSizeBytes / MB}MB. Your account needs more disk size per instance to run this container. The default disk size is 2GB.`
|
65976
|
-
);
|
65977
|
-
}
|
65978
|
-
}
|
65979
66150
|
var import_fs13, import_path10;
|
65980
66151
|
var init_build2 = __esm({
|
65981
66152
|
"src/cloudchamber/build.ts"() {
|
@@ -65987,6 +66158,7 @@ var init_build2 = __esm({
|
|
65987
66158
|
init_errors();
|
65988
66159
|
init_logger();
|
65989
66160
|
init_user2();
|
66161
|
+
init_limits();
|
65990
66162
|
init_locations();
|
65991
66163
|
__name(buildYargs, "buildYargs");
|
65992
66164
|
__name(pushYargs, "pushYargs");
|
@@ -65994,7 +66166,6 @@ var init_build2 = __esm({
|
|
65994
66166
|
__name(buildCommand, "buildCommand");
|
65995
66167
|
__name(pushCommand, "pushCommand");
|
65996
66168
|
__name(checkImagePlatform, "checkImagePlatform");
|
65997
|
-
__name(ensureDiskLimits, "ensureDiskLimits");
|
65998
66169
|
}
|
65999
66170
|
});
|
66000
66171
|
|
@@ -66995,90 +67166,14 @@ async function promptForLabels(labels, initiallySelected, allowSkipping) {
|
|
66995
67166
|
}
|
66996
67167
|
return [];
|
66997
67168
|
}
|
66998
|
-
async function promptForInstanceType(allowSkipping) {
|
66999
|
-
let options = [
|
67000
|
-
{ label: "dev: 1/16 vCPU, 256 MiB memory, 2 GB disk", value: "dev" },
|
67001
|
-
{ label: "basic: 1/4 vCPU, 1 GiB memory, 4 GB disk", value: "basic" },
|
67002
|
-
{ label: "standard: 1/2 vCPU, 4 GiB memory, 4 GB disk", value: "standard" }
|
67003
|
-
];
|
67004
|
-
if (allowSkipping) {
|
67005
|
-
options = [{ label: "Do not set", value: "skip" }].concat(options);
|
67006
|
-
}
|
67007
|
-
const action = await inputPrompt({
|
67008
|
-
question: "Which instance type should we use for your container?",
|
67009
|
-
label: "",
|
67010
|
-
defaultValue: false,
|
67011
|
-
helpText: "",
|
67012
|
-
type: "select",
|
67013
|
-
options
|
67014
|
-
});
|
67015
|
-
switch (action) {
|
67016
|
-
case "dev":
|
67017
|
-
return "dev" /* DEV */;
|
67018
|
-
case "basic":
|
67019
|
-
return "basic" /* BASIC */;
|
67020
|
-
case "standard":
|
67021
|
-
return "standard" /* STANDARD */;
|
67022
|
-
default:
|
67023
|
-
return void 0;
|
67024
|
-
}
|
67025
|
-
}
|
67026
67169
|
function resolveMemory(args, config) {
|
67027
|
-
const
|
67170
|
+
const MiB2 = 1024 * 1024;
|
67028
67171
|
const memory = args.memory ?? config.memory;
|
67029
67172
|
if (memory !== void 0) {
|
67030
|
-
return Math.round(parseByteSize(memory, 1024) /
|
67173
|
+
return Math.round(parseByteSize(memory, 1024) / MiB2);
|
67031
67174
|
}
|
67032
67175
|
return void 0;
|
67033
67176
|
}
|
67034
|
-
function checkInstanceType(args, config) {
|
67035
|
-
const instance_type = args.instanceType ?? config.instance_type;
|
67036
|
-
if (instance_type === void 0) {
|
67037
|
-
return;
|
67038
|
-
}
|
67039
|
-
if (args.memory !== void 0 || args.vcpu !== void 0) {
|
67040
|
-
throw new UserError(
|
67041
|
-
`Field "instance_type" is mutually exclusive with "memory" and "vcpu". These fields cannot be set together.`
|
67042
|
-
);
|
67043
|
-
}
|
67044
|
-
switch (instance_type) {
|
67045
|
-
case "dev":
|
67046
|
-
return "dev" /* DEV */;
|
67047
|
-
case "basic":
|
67048
|
-
return "basic" /* BASIC */;
|
67049
|
-
case "standard":
|
67050
|
-
return "standard" /* STANDARD */;
|
67051
|
-
default:
|
67052
|
-
throw new UserError(
|
67053
|
-
`"instance_type" field value is expected to be one of "dev", "basic", or "standard", but got "${instance_type}"`
|
67054
|
-
);
|
67055
|
-
}
|
67056
|
-
}
|
67057
|
-
function inferInstanceType(configuration) {
|
67058
|
-
if (configuration?.disk?.size_mb !== void 0 && configuration?.memory_mib !== void 0 && configuration?.vcpu !== void 0) {
|
67059
|
-
if (configuration.disk.size_mb === 2e3 && configuration.memory_mib === 256 && configuration.vcpu === 0.0625) {
|
67060
|
-
return "dev" /* DEV */;
|
67061
|
-
} else if (configuration.disk.size_mb === 4e3 && configuration.memory_mib === 1024 && configuration.vcpu === 0.25) {
|
67062
|
-
return "basic" /* BASIC */;
|
67063
|
-
} else if (configuration.disk.size_mb === 4e3 && configuration.memory_mib === 4096 && configuration.vcpu === 0.5) {
|
67064
|
-
return "standard" /* STANDARD */;
|
67065
|
-
}
|
67066
|
-
}
|
67067
|
-
}
|
67068
|
-
function cleanForInstanceType(app) {
|
67069
|
-
if (!("configuration" in app)) {
|
67070
|
-
return app;
|
67071
|
-
}
|
67072
|
-
const instance_type = inferInstanceType(app.configuration);
|
67073
|
-
if (instance_type !== void 0) {
|
67074
|
-
app.configuration.instance_type = instance_type;
|
67075
|
-
}
|
67076
|
-
delete app.configuration.disk;
|
67077
|
-
delete app.configuration.memory;
|
67078
|
-
delete app.configuration.memory_mib;
|
67079
|
-
delete app.configuration.vcpu;
|
67080
|
-
return app;
|
67081
|
-
}
|
67082
67177
|
var cloudchamberScope, imageRe;
|
67083
67178
|
var init_common = __esm({
|
67084
67179
|
"src/cloudchamber/common.ts"() {
|
@@ -67125,11 +67220,7 @@ var init_common = __esm({
|
|
67125
67220
|
__name(sortLabels, "sortLabels");
|
67126
67221
|
__name(collectLabels, "collectLabels");
|
67127
67222
|
__name(promptForLabels, "promptForLabels");
|
67128
|
-
__name(promptForInstanceType, "promptForInstanceType");
|
67129
67223
|
__name(resolveMemory, "resolveMemory");
|
67130
|
-
__name(checkInstanceType, "checkInstanceType");
|
67131
|
-
__name(inferInstanceType, "inferInstanceType");
|
67132
|
-
__name(cleanForInstanceType, "cleanForInstanceType");
|
67133
67224
|
}
|
67134
67225
|
});
|
67135
67226
|
|
@@ -68158,6 +68249,7 @@ var init_deploy = __esm({
|
|
68158
68249
|
init_containers_shared();
|
68159
68250
|
init_common();
|
68160
68251
|
init_diff();
|
68252
|
+
init_instance_type();
|
68161
68253
|
init_config2();
|
68162
68254
|
init_errors();
|
68163
68255
|
init_user2();
|
@@ -68411,7 +68503,7 @@ async function maybeBuildContainer(containerConfig, imageTag, dryRun, pathToDock
|
|
68411
68503
|
},
|
68412
68504
|
pathToDocker,
|
68413
68505
|
!dryRun,
|
68414
|
-
|
68506
|
+
containerConfig
|
68415
68507
|
);
|
68416
68508
|
if (buildResult.pushed) {
|
68417
68509
|
return { newImageLink: buildResult.image };
|
@@ -68524,10 +68616,10 @@ var init_config3 = __esm({
|
|
68524
68616
|
}
|
68525
68617
|
};
|
68526
68618
|
let instanceTypeOrLimits;
|
68527
|
-
const
|
68619
|
+
const MB2 = 1e3 * 1e3;
|
68528
68620
|
if (container.configuration?.disk !== void 0 || container.configuration?.vcpu !== void 0 || container.configuration?.memory_mib !== void 0) {
|
68529
68621
|
instanceTypeOrLimits = {
|
68530
|
-
disk_bytes: (container.configuration?.disk?.size_mb ?? 2e3) *
|
68622
|
+
disk_bytes: (container.configuration?.disk?.size_mb ?? 2e3) * MB2,
|
68531
68623
|
// defaults to 2GB in bytes
|
68532
68624
|
vcpu: container.configuration?.vcpu ?? 0.0625,
|
68533
68625
|
memory_mib: container.configuration?.memory_mib ?? 256
|
@@ -68538,7 +68630,7 @@ var init_config3 = __esm({
|
|
68538
68630
|
};
|
68539
68631
|
} else {
|
68540
68632
|
instanceTypeOrLimits = {
|
68541
|
-
disk_bytes: (container.instance_type.disk_mb ?? 2e3) *
|
68633
|
+
disk_bytes: (container.instance_type.disk_mb ?? 2e3) * MB2,
|
68542
68634
|
vcpu: container.instance_type.vcpu ?? 0.0625,
|
68543
68635
|
memory_mib: container.instance_type.memory_mib ?? 256
|
68544
68636
|
};
|
@@ -80112,6 +80204,7 @@ var init_apply = __esm({
|
|
80112
80204
|
init_sortObjectRecursive();
|
80113
80205
|
init_common();
|
80114
80206
|
init_diff();
|
80207
|
+
init_instance_type();
|
80115
80208
|
__name(mergeDeep3, "mergeDeep");
|
80116
80209
|
__name(isObject2, "isObject");
|
80117
80210
|
__name(applyCommandOptionalYargs, "applyCommandOptionalYargs");
|
@@ -81202,6 +81295,7 @@ var init_create2 = __esm({
|
|
81202
81295
|
init_locations2();
|
81203
81296
|
init_common();
|
81204
81297
|
init_wrap();
|
81298
|
+
init_instance_type();
|
81205
81299
|
init_locations();
|
81206
81300
|
init_network();
|
81207
81301
|
init_ssh();
|
@@ -82204,6 +82298,7 @@ var init_modify = __esm({
|
|
82204
82298
|
init_locations2();
|
82205
82299
|
init_common();
|
82206
82300
|
init_wrap();
|
82301
|
+
init_instance_type();
|
82207
82302
|
init_locations();
|
82208
82303
|
init_ssh();
|
82209
82304
|
__name(modifyCommandOptionalYargs, "modifyCommandOptionalYargs");
|
@@ -178607,14 +178702,15 @@ function switchHost(originalUrl, host, zonePreview) {
|
|
178607
178702
|
return url4;
|
178608
178703
|
}
|
178609
178704
|
async function createPreviewSession(complianceConfig, account, ctx, abortSignal) {
|
178610
|
-
const { accountId } = account;
|
178705
|
+
const { accountId, apiToken } = account;
|
178611
178706
|
const initUrl = ctx.zone ? `/zones/${ctx.zone}/workers/edge-preview` : `/accounts/${accountId}/workers/subdomain/edge-preview`;
|
178612
178707
|
const { exchange_url } = await fetchResult(
|
178613
178708
|
complianceConfig,
|
178614
178709
|
initUrl,
|
178615
178710
|
void 0,
|
178616
178711
|
void 0,
|
178617
|
-
abortSignal
|
178712
|
+
abortSignal,
|
178713
|
+
apiToken
|
178618
178714
|
);
|
178619
178715
|
const switchedExchangeUrl = switchHost(
|
178620
178716
|
exchange_url,
|
@@ -178881,7 +178977,7 @@ async function createRemoteWorkerInit(props) {
|
|
178881
178977
|
async function getWorkerAccountAndContext(props) {
|
178882
178978
|
const workerAccount = {
|
178883
178979
|
accountId: props.accountId,
|
178884
|
-
apiToken: requireApiToken()
|
178980
|
+
apiToken: props.apiToken ?? requireApiToken()
|
178885
178981
|
};
|
178886
178982
|
const zoneId = await getZoneIdForPreview(props.complianceConfig, {
|
178887
178983
|
host: props.host,
|
@@ -179113,6 +179209,7 @@ var init_RemoteRuntimeController = __esm({
|
|
179113
179209
|
this.#session ??= await this.#previewSession({
|
179114
179210
|
complianceConfig: { compliance_region: config.complianceRegion },
|
179115
179211
|
accountId: auth.accountId,
|
179212
|
+
apiToken: auth.apiToken,
|
179116
179213
|
env: config.env,
|
179117
179214
|
// deprecated service environments -- just pass it through for now
|
179118
179215
|
legacyEnv: !config.legacy?.enableServiceEnvironments,
|
@@ -179503,34 +179600,53 @@ function pickRemoteBindings(bindings) {
|
|
179503
179600
|
})
|
179504
179601
|
);
|
179505
179602
|
}
|
179506
|
-
async function maybeStartOrUpdateRemoteProxySession(
|
179507
|
-
if (
|
179508
|
-
const
|
179509
|
-
const config = readConfig({
|
179603
|
+
async function maybeStartOrUpdateRemoteProxySession(wranglerOrWorkerConfigObject, preExistingRemoteProxySessionData, auth) {
|
179604
|
+
if ("path" in wranglerOrWorkerConfigObject) {
|
179605
|
+
const wranglerConfigObject = wranglerOrWorkerConfigObject;
|
179606
|
+
const config = readConfig({
|
179607
|
+
config: wranglerConfigObject.path,
|
179608
|
+
env: wranglerConfigObject.environment
|
179609
|
+
});
|
179510
179610
|
(0, import_node_assert33.default)(config.name);
|
179511
|
-
|
179611
|
+
wranglerOrWorkerConfigObject = {
|
179512
179612
|
name: config.name,
|
179513
179613
|
complianceRegion: getCloudflareComplianceRegion(config),
|
179514
179614
|
bindings: convertConfigBindingsToStartWorkerBindings(config) ?? {}
|
179515
179615
|
};
|
179516
179616
|
}
|
179517
|
-
const
|
179518
|
-
const remoteBindings = pickRemoteBindings(
|
179519
|
-
|
179520
|
-
|
179521
|
-
|
179522
|
-
preExistingRemoteProxySessionData?.remoteBindings
|
179617
|
+
const workerConfigObject = wranglerOrWorkerConfigObject;
|
179618
|
+
const remoteBindings = pickRemoteBindings(workerConfigObject.bindings);
|
179619
|
+
const authSameAsBefore = deepStrictEqual(
|
179620
|
+
auth,
|
179621
|
+
preExistingRemoteProxySessionData?.auth
|
179523
179622
|
);
|
179524
|
-
|
179525
|
-
|
179526
|
-
|
179527
|
-
|
179528
|
-
|
179529
|
-
|
179530
|
-
|
179623
|
+
let remoteProxySession = preExistingRemoteProxySessionData?.session;
|
179624
|
+
if (!authSameAsBefore) {
|
179625
|
+
if (preExistingRemoteProxySessionData?.session) {
|
179626
|
+
await preExistingRemoteProxySessionData.session.dispose();
|
179627
|
+
}
|
179628
|
+
remoteProxySession = await startRemoteProxySession(remoteBindings, {
|
179629
|
+
workerName: workerConfigObject.name,
|
179630
|
+
complianceRegion: workerConfigObject.complianceRegion,
|
179631
|
+
auth
|
179632
|
+
});
|
179633
|
+
} else {
|
179634
|
+
const remoteBindingsAreSameAsBefore = deepStrictEqual(
|
179635
|
+
remoteBindings,
|
179636
|
+
preExistingRemoteProxySessionData?.remoteBindings
|
179637
|
+
);
|
179638
|
+
if (!remoteBindingsAreSameAsBefore) {
|
179639
|
+
if (!remoteProxySession) {
|
179640
|
+
if (Object.keys(remoteBindings).length > 0) {
|
179641
|
+
remoteProxySession = await startRemoteProxySession(remoteBindings, {
|
179642
|
+
workerName: workerConfigObject.name,
|
179643
|
+
complianceRegion: workerConfigObject.complianceRegion,
|
179644
|
+
auth
|
179645
|
+
});
|
179646
|
+
}
|
179647
|
+
} else {
|
179648
|
+
await remoteProxySession.updateBindings(remoteBindings);
|
179531
179649
|
}
|
179532
|
-
} else {
|
179533
|
-
await remoteProxySession.updateBindings(remoteBindings);
|
179534
179650
|
}
|
179535
179651
|
}
|
179536
179652
|
await remoteProxySession?.ready;
|
@@ -179674,7 +179790,8 @@ async function convertToConfigBundle(event) {
|
|
179674
179790
|
event.config.containers?.map((c6) => c6.class_name)
|
179675
179791
|
),
|
179676
179792
|
containerBuildId: event.config.dev?.containerBuildId,
|
179677
|
-
containerEngine: event.config.dev.containerEngine
|
179793
|
+
containerEngine: event.config.dev.containerEngine,
|
179794
|
+
enableContainers: event.config.dev.enableContainers ?? true
|
179678
179795
|
};
|
179679
179796
|
}
|
179680
179797
|
async function getContainerDevOptions(containersConfig, containerBuildId) {
|
@@ -179764,14 +179881,22 @@ var init_LocalRuntimeController = __esm({
|
|
179764
179881
|
const configBundle = await convertToConfigBundle(data);
|
179765
179882
|
const experimentalRemoteBindings = data.config.dev.experimentalRemoteBindings ?? false;
|
179766
179883
|
if (experimentalRemoteBindings && !data.config.dev?.remote) {
|
179767
|
-
const { maybeStartOrUpdateRemoteProxySession: maybeStartOrUpdateRemoteProxySession2 } = await Promise.resolve().then(() => (init_remoteBindings(), remoteBindings_exports));
|
179884
|
+
const { maybeStartOrUpdateRemoteProxySession: maybeStartOrUpdateRemoteProxySession2, pickRemoteBindings: pickRemoteBindings2 } = await Promise.resolve().then(() => (init_remoteBindings(), remoteBindings_exports));
|
179885
|
+
const remoteBindings = pickRemoteBindings2(
|
179886
|
+
convertCfWorkerInitBindingsToBindings(configBundle.bindings) ?? {}
|
179887
|
+
);
|
179888
|
+
const auth = Object.keys(remoteBindings).length === 0 ? (
|
179889
|
+
// If there are no remote bindings (this is a local only session) there's no need to get auth data
|
179890
|
+
void 0
|
179891
|
+
) : await unwrapHook(data.config.dev.auth);
|
179768
179892
|
this.#remoteProxySessionData = await maybeStartOrUpdateRemoteProxySession2(
|
179769
179893
|
{
|
179770
179894
|
name: configBundle.name,
|
179771
179895
|
complianceRegion: configBundle.complianceRegion,
|
179772
|
-
bindings:
|
179896
|
+
bindings: remoteBindings
|
179773
179897
|
},
|
179774
|
-
this.#remoteProxySessionData ?? null
|
179898
|
+
this.#remoteProxySessionData ?? null,
|
179899
|
+
auth
|
179775
179900
|
);
|
179776
179901
|
}
|
179777
179902
|
if (data.config.containers?.length && data.config.dev.enableContainers && this.#currentContainerBuildId !== data.config.dev.containerBuildId) {
|
@@ -184156,7 +184281,10 @@ async function getPlatformProxy(options = {}) {
|
|
184156
184281
|
});
|
184157
184282
|
let remoteProxySession = void 0;
|
184158
184283
|
if (experimentalRemoteBindings && config.configPath) {
|
184159
|
-
remoteProxySession = (await maybeStartOrUpdateRemoteProxySession(
|
184284
|
+
remoteProxySession = (await maybeStartOrUpdateRemoteProxySession({
|
184285
|
+
path: config.configPath,
|
184286
|
+
environment: env6
|
184287
|
+
}) ?? {}).session;
|
184160
184288
|
}
|
184161
184289
|
const miniflareOptions = await getMiniflareOptionsFromConfig({
|
184162
184290
|
config,
|
@@ -184228,7 +184356,8 @@ async function getMiniflareOptionsFromConfig(args) {
|
|
184228
184356
|
containerDOClassNames: new Set(
|
184229
184357
|
config.containers?.map((c6) => c6.class_name)
|
184230
184358
|
),
|
184231
|
-
containerBuildId: void 0
|
184359
|
+
containerBuildId: void 0,
|
184360
|
+
enableContainers: config.dev.enable_containers
|
184232
184361
|
},
|
184233
184362
|
remoteProxyConnectionString,
|
184234
184363
|
remoteBindingsEnabled
|
@@ -184295,6 +184424,7 @@ function unstable_getMiniflareWorkerOptions(configOrConfigPath, env6, options) {
|
|
184295
184424
|
config.containers?.map((c6) => c6.class_name)
|
184296
184425
|
);
|
184297
184426
|
const bindings = getBindings2(config, env6, options?.envFiles, true, {}, true);
|
184427
|
+
const enableContainers = options?.overrides?.enableContainers !== void 0 ? options?.overrides?.enableContainers : config.dev.enable_containers;
|
184298
184428
|
const { bindingOptions, externalWorkers } = buildMiniflareBindingOptions(
|
184299
184429
|
{
|
184300
184430
|
name: config.name,
|
@@ -184308,7 +184438,8 @@ function unstable_getMiniflareWorkerOptions(configOrConfigPath, env6, options) {
|
|
184308
184438
|
imagesLocalMode: !!options?.imagesLocalMode,
|
184309
184439
|
tails: config.tail_consumers,
|
184310
184440
|
containerDOClassNames,
|
184311
|
-
containerBuildId: options?.containerBuildId
|
184441
|
+
containerBuildId: options?.containerBuildId,
|
184442
|
+
enableContainers
|
184312
184443
|
},
|
184313
184444
|
options?.remoteProxyConnectionString,
|
184314
184445
|
options?.remoteBindingsEnabled ?? false
|
@@ -184342,11 +184473,11 @@ function unstable_getMiniflareWorkerOptions(configOrConfigPath, env6, options) {
|
|
184342
184473
|
className: binding.class_name,
|
184343
184474
|
scriptName: binding.script_name,
|
184344
184475
|
useSQLite,
|
184345
|
-
container: getImageNameFromDOClassName({
|
184476
|
+
container: enableContainers && config.containers?.length ? getImageNameFromDOClassName({
|
184346
184477
|
doClassName: binding.class_name,
|
184347
184478
|
containerDOClassNames,
|
184348
184479
|
containerBuildId: options?.containerBuildId
|
184349
|
-
})
|
184480
|
+
}) : void 0
|
184350
184481
|
}
|
184351
184482
|
];
|
184352
184483
|
})
|