wrangler 4.20.5 → 4.21.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.
@@ -20469,7 +20469,7 @@ var init_UpdateApplicationRolloutRequest = __esm({
20469
20469
  });
20470
20470
 
20471
20471
  // ../containers-shared/src/client/core/request.ts
20472
- var import_undici, isDefined, isString, isStringWithValue, isBlob, base64, getQueryString, getUrl, getFormData, resolve5, getHeaders, getRequestBody, isResponseSchemaV4, sendRequest, getResponseHeader, getResponseBody, catchErrorCodes, request;
20472
+ var import_undici, isDefined, isString, isStringWithValue, isBlob, base64, getQueryString, getUrl, getFormData, resolve5, getHeaders, getRequestBody, isResponseSchemaV4, parseResponseSchemaV4, sendRequest, getResponseHeader, getResponseBody, catchErrorCodes, request;
20473
20473
  var init_request = __esm({
20474
20474
  "../containers-shared/src/client/core/request.ts"() {
20475
20475
  init_import_meta_url();
@@ -20615,6 +20615,27 @@ var init_request = __esm({
20615
20615
  isResponseSchemaV4 = /* @__PURE__ */ __name((config, _options) => {
20616
20616
  return config.BASE.endsWith("/containers");
20617
20617
  }, "isResponseSchemaV4");
20618
+ parseResponseSchemaV4 = /* @__PURE__ */ __name((url4, response, responseHeader, responseBody) => {
20619
+ const fetchResult2 = typeof responseBody === "object" ? responseBody : JSON.parse(responseBody);
20620
+ const ok = response.ok && fetchResult2.success;
20621
+ let result;
20622
+ if (ok) {
20623
+ if (fetchResult2.result !== void 0) {
20624
+ result = fetchResult2.result;
20625
+ } else {
20626
+ result = {};
20627
+ }
20628
+ } else {
20629
+ result = { error: fetchResult2.errors?.[0].message };
20630
+ }
20631
+ return {
20632
+ url: url4,
20633
+ ok,
20634
+ status: response.status,
20635
+ statusText: response.statusText,
20636
+ body: responseHeader ?? result
20637
+ };
20638
+ }, "parseResponseSchemaV4");
20618
20639
  sendRequest = /* @__PURE__ */ __name(async (config, options, url4, body, formData, headers, onCancel) => {
20619
20640
  const controller = new AbortController();
20620
20641
  const request4 = {
@@ -20701,23 +20722,23 @@ var init_request = __esm({
20701
20722
  response,
20702
20723
  options.responseHeader
20703
20724
  );
20704
- const parseResponseSchemaV4 = /* @__PURE__ */ __name((body2) => {
20705
- const fetchResult2 = body2;
20706
- return {
20725
+ let result;
20726
+ if (isResponseSchemaV4(config, options)) {
20727
+ result = parseResponseSchemaV4(
20728
+ url4,
20729
+ response,
20730
+ responseHeader,
20731
+ responseBody
20732
+ );
20733
+ } else {
20734
+ result = {
20707
20735
  url: url4,
20708
- ok: response.ok && fetchResult2.success,
20736
+ ok: response.ok,
20709
20737
  status: response.status,
20710
20738
  statusText: response.statusText,
20711
- body: responseHeader ?? fetchResult2.result
20739
+ body: responseHeader ?? responseBody
20712
20740
  };
20713
- }, "parseResponseSchemaV4");
20714
- const result = isResponseSchemaV4(config, options) ? parseResponseSchemaV4(responseBody) : {
20715
- url: url4,
20716
- ok: response.ok,
20717
- status: response.status,
20718
- statusText: response.statusText,
20719
- body: responseHeader ?? responseBody
20720
- };
20741
+ }
20721
20742
  catchErrorCodes(options, result);
20722
20743
  resolve24(result.body);
20723
20744
  }
@@ -29487,7 +29508,7 @@ var name, version;
29487
29508
  var init_package = __esm({
29488
29509
  "package.json"() {
29489
29510
  name = "wrangler";
29490
- version = "4.20.5";
29511
+ version = "4.21.0";
29491
29512
  }
29492
29513
  });
29493
29514
 
@@ -37670,6 +37691,11 @@ function applyPythonConfig(config, args) {
37670
37691
  if (!config.rules.some((rule) => rule.type === "PythonModule")) {
37671
37692
  config.rules.push({ type: "PythonModule", globs: ["**/*.py"] });
37672
37693
  }
37694
+ if (!config.rules.some(
37695
+ (rule) => rule.type === "Data" && rule.globs.includes("vendor/**/*.so")
37696
+ )) {
37697
+ config.rules.push({ type: "Data", globs: ["vendor/**/*.so"] });
37698
+ }
37673
37699
  if (!config.compatibility_flags.includes("python_workers")) {
37674
37700
  throw new UserError(
37675
37701
  "The `python_workers` compatibility flag is required to use Python."
@@ -49290,9 +49316,6 @@ function getAuthFromEnv() {
49290
49316
  return { apiToken };
49291
49317
  }
49292
49318
  }
49293
- function setLoginScopeKeys(scopes) {
49294
- DefaultScopeKeys = scopes;
49295
- }
49296
49319
  function validateScopeKeys(scopes) {
49297
49320
  return scopes.every((scope) => scope in DefaultScopes);
49298
49321
  }
@@ -49760,7 +49783,7 @@ function listScopes(message = "\u{1F481} Available scopes:") {
49760
49783
  logger.log(message);
49761
49784
  const data = DefaultScopeKeys.map((scope) => ({
49762
49785
  Scope: scope,
49763
- Description: AllScopes[scope]
49786
+ Description: DefaultScopes[scope]
49764
49787
  }));
49765
49788
  logger.table(data);
49766
49789
  }
@@ -49871,7 +49894,7 @@ async function getJSONFromResponse(response) {
49871
49894
  );
49872
49895
  }
49873
49896
  }
49874
- var import_node_assert2, import_node_crypto2, import_node_fs6, import_node_http, import_node_path12, import_node_url4, import_node_util2, import_toml3, import_undici3, USER_AUTH_CONFIG_PATH, DefaultScopes, OptionalScopes, AllScopes, DefaultScopeKeys, LocalState, ErrorOAuth2, ErrorUnknown, ErrorNoAuthCode, ErrorInvalidReturnedStateParam, ErrorInvalidJson, ErrorInvalidScope, ErrorInvalidRequest, ErrorInvalidToken, ErrorAuthenticationGrant, ErrorUnauthorizedClient, ErrorAccessDenied, ErrorUnsupportedResponseType, ErrorServerError, ErrorTemporarilyUnavailable, ErrorAccessTokenResponse, ErrorInvalidClient, ErrorInvalidGrant, ErrorUnsupportedGrantType, RawErrorToErrorClassMap, RECOMMENDED_CODE_VERIFIER_LENGTH, RECOMMENDED_STATE_LENGTH, PKCE_CHARSET;
49897
+ var import_node_assert2, import_node_crypto2, import_node_fs6, import_node_http, import_node_path12, import_node_url4, import_node_util2, import_toml3, import_undici3, USER_AUTH_CONFIG_PATH, DefaultScopes, DefaultScopeKeys, LocalState, ErrorOAuth2, ErrorUnknown, ErrorNoAuthCode, ErrorInvalidReturnedStateParam, ErrorInvalidJson, ErrorInvalidScope, ErrorInvalidRequest, ErrorInvalidToken, ErrorAuthenticationGrant, ErrorUnauthorizedClient, ErrorAccessDenied, ErrorUnsupportedResponseType, ErrorServerError, ErrorTemporarilyUnavailable, ErrorAccessTokenResponse, ErrorInvalidClient, ErrorInvalidGrant, ErrorUnsupportedGrantType, RawErrorToErrorClassMap, RECOMMENDED_CODE_VERIFIER_LENGTH, RECOMMENDED_STATE_LENGTH, PKCE_CHARSET;
49875
49898
  var init_user = __esm({
49876
49899
  "src/user/user.ts"() {
49877
49900
  init_import_meta_url();
@@ -49917,17 +49940,11 @@ var init_user = __esm({
49917
49940
  "ai:write": "See and change Workers AI catalog and assets",
49918
49941
  "queues:write": "See and change Cloudflare Queues settings and data",
49919
49942
  "pipelines:write": "See and change Cloudflare Pipelines configurations and data",
49920
- "secrets_store:write": "See and change secrets + stores within the Secrets Store"
49921
- };
49922
- OptionalScopes = {
49943
+ "secrets_store:write": "See and change secrets + stores within the Secrets Store",
49944
+ "containers:write": "Manage Workers Containers",
49923
49945
  "cloudchamber:write": "Manage Cloudchamber"
49924
49946
  };
49925
- AllScopes = {
49926
- ...DefaultScopes,
49927
- ...OptionalScopes
49928
- };
49929
49947
  DefaultScopeKeys = Object.keys(DefaultScopes);
49930
- __name(setLoginScopeKeys, "setLoginScopeKeys");
49931
49948
  __name(validateScopeKeys, "validateScopeKeys");
49932
49949
  __name(getCallbackUrl, "getCallbackUrl");
49933
49950
  LocalState = {
@@ -52126,6 +52143,16 @@ function isValidPythonPackageName(name2) {
52126
52143
  const regex2 = /^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$/i;
52127
52144
  return regex2.test(name2);
52128
52145
  }
52146
+ function filterPythonVendorModules(isPythonEntrypoint, modules) {
52147
+ if (!isPythonEntrypoint) {
52148
+ return modules;
52149
+ }
52150
+ return modules.filter((m6) => !m6.name.startsWith("vendor/"));
52151
+ }
52152
+ function getPythonVendorModulesSize(modules) {
52153
+ const vendorModules = modules.filter((m6) => m6.name.startsWith("vendor/"));
52154
+ return vendorModules.reduce((total, m6) => total + m6.content.length, 0);
52155
+ }
52129
52156
  async function findAdditionalModules(entry, rules, attachSourcemaps = false) {
52130
52157
  const files = getFiles(
52131
52158
  entry.configPath,
@@ -52176,24 +52203,37 @@ async function findAdditionalModules(entry, rules, attachSourcemaps = false) {
52176
52203
  }
52177
52204
  if (modules.length > 0) {
52178
52205
  logger.info(`Attaching additional modules:`);
52206
+ const filteredModules = filterPythonVendorModules(
52207
+ isPythonEntrypoint,
52208
+ modules
52209
+ );
52210
+ const vendorModulesSize = getPythonVendorModulesSize(modules);
52179
52211
  const totalSize = modules.reduce(
52180
52212
  (previous, { content }) => previous + content.length,
52181
52213
  0
52182
52214
  );
52183
- logger.table([
52184
- ...modules.map(({ name: name2, type, content }) => {
52215
+ const tableEntries = [
52216
+ ...filteredModules.map(({ name: name2, type, content }) => {
52185
52217
  return {
52186
52218
  Name: name2,
52187
52219
  Type: type ?? "",
52188
52220
  Size: type === "python-requirement" ? "" : `${(content.length / 1024).toFixed(2)} KiB`
52189
52221
  };
52190
- }),
52191
- {
52192
- Name: `Total (${modules.length} module${modules.length > 1 ? "s" : ""})`,
52222
+ })
52223
+ ];
52224
+ if (isPythonEntrypoint && vendorModulesSize > 0) {
52225
+ tableEntries.push({
52226
+ Name: "Vendored Modules",
52193
52227
  Type: "",
52194
- Size: `${(totalSize / 1024).toFixed(2)} KiB`
52195
- }
52196
- ]);
52228
+ Size: `${(vendorModulesSize / 1024).toFixed(2)} KiB`
52229
+ });
52230
+ }
52231
+ tableEntries.push({
52232
+ Name: `Total (${modules.length} module${modules.length > 1 ? "s" : ""})`,
52233
+ Type: "",
52234
+ Size: `${(totalSize / 1024).toFixed(2)} KiB`
52235
+ });
52236
+ logger.table(tableEntries);
52197
52237
  }
52198
52238
  return modules;
52199
52239
  }
@@ -52286,6 +52326,8 @@ var init_find_additional_modules = __esm({
52286
52326
  init_source_maps();
52287
52327
  __name(getFiles, "getFiles");
52288
52328
  __name(isValidPythonPackageName, "isValidPythonPackageName");
52329
+ __name(filterPythonVendorModules, "filterPythonVendorModules");
52330
+ __name(getPythonVendorModulesSize, "getPythonVendorModulesSize");
52289
52331
  __name(findAdditionalModules, "findAdditionalModules");
52290
52332
  __name(matchFiles, "matchFiles");
52291
52333
  __name(findAdditionalModuleWatchDirs, "findAdditionalModuleWatchDirs");
@@ -53725,7 +53767,7 @@ var require_update_check = __commonJS({
53725
53767
  var { tmpdir } = require("os");
53726
53768
  var registryUrl = require_registry_url();
53727
53769
  var writeFile11 = promisify3(fs24.writeFile);
53728
- var mkdir7 = promisify3(fs24.mkdir);
53770
+ var mkdir6 = promisify3(fs24.mkdir);
53729
53771
  var readFile18 = promisify3(fs24.readFile);
53730
53772
  var compareVersions = /* @__PURE__ */ __name((a5, b6) => a5.localeCompare(b6, "en-US", { numeric: true }), "compareVersions");
53731
53773
  var encode = /* @__PURE__ */ __name((value) => encodeURIComponent(value).replace(/^%40/, "@"), "encode");
@@ -53733,7 +53775,7 @@ var require_update_check = __commonJS({
53733
53775
  const rootDir = tmpdir();
53734
53776
  const subDir = join24(rootDir, "update-check");
53735
53777
  if (!fs24.existsSync(subDir)) {
53736
- await mkdir7(subDir);
53778
+ await mkdir6(subDir);
53737
53779
  }
53738
53780
  let name2 = `${details.name}-${distTag}.json`;
53739
53781
  if (details.scope) {
@@ -59660,139 +59702,6 @@ Ensure all assets in your assets directory "${dir}" conform with the Workers max
59660
59702
  }
59661
59703
  });
59662
59704
 
59663
- // src/versions/api.ts
59664
- async function fetchVersion(complianceConfig, accountId, workerName, versionId, versionCache) {
59665
- const cachedVersion = versionCache?.get(versionId);
59666
- if (cachedVersion) {
59667
- return cachedVersion;
59668
- }
59669
- const version5 = await fetchResult(
59670
- complianceConfig,
59671
- `/accounts/${accountId}/workers/scripts/${workerName}/versions/${versionId}`
59672
- );
59673
- versionCache?.set(version5.id, version5);
59674
- return version5;
59675
- }
59676
- async function fetchVersions(complianceConfig, accountId, workerName, versionCache, ...versionIds) {
59677
- return Promise.all(
59678
- versionIds.map(
59679
- (versionId) => fetchVersion(
59680
- complianceConfig,
59681
- accountId,
59682
- workerName,
59683
- versionId,
59684
- versionCache
59685
- )
59686
- )
59687
- );
59688
- }
59689
- async function fetchLatestDeployments(complianceConfig, accountId, workerName) {
59690
- const { deployments } = await fetchResult(
59691
- complianceConfig,
59692
- `/accounts/${accountId}/workers/scripts/${workerName}/deployments`
59693
- );
59694
- return deployments;
59695
- }
59696
- async function fetchLatestDeployment(complianceConfig, accountId, workerName) {
59697
- const deployments = await fetchLatestDeployments(
59698
- complianceConfig,
59699
- accountId,
59700
- workerName
59701
- );
59702
- return deployments.at(0);
59703
- }
59704
- async function fetchDeploymentVersions(complianceConfig, accountId, workerName, deployment, versionCache) {
59705
- if (!deployment) {
59706
- return [[], /* @__PURE__ */ new Map()];
59707
- }
59708
- const versionTraffic = new Map(
59709
- deployment.versions.map((v7) => [v7.version_id, v7.percentage])
59710
- );
59711
- const versions2 = await fetchVersions(
59712
- complianceConfig,
59713
- accountId,
59714
- workerName,
59715
- versionCache,
59716
- ...versionTraffic.keys()
59717
- );
59718
- return [versions2, versionTraffic];
59719
- }
59720
- async function fetchDeployableVersions(complianceConfig, accountId, workerName, versionCache) {
59721
- const { items: versions2 } = await fetchResult(
59722
- complianceConfig,
59723
- `/accounts/${accountId}/workers/scripts/${workerName}/versions?deployable=true`
59724
- );
59725
- for (const version5 of versions2) {
59726
- versionCache.set(version5.id, version5);
59727
- }
59728
- return versions2;
59729
- }
59730
- async function createDeployment(complianceConfig, accountId, workerName, versionTraffic, message, force) {
59731
- return await fetchResult(
59732
- complianceConfig,
59733
- `/accounts/${accountId}/workers/scripts/${workerName}/deployments${force ? "?force=true" : ""}`,
59734
- {
59735
- method: "POST",
59736
- headers: { "Content-Type": "application/json" },
59737
- body: JSON.stringify({
59738
- strategy: "percentage",
59739
- versions: Array.from(versionTraffic).map(
59740
- ([version_id, percentage]) => ({ version_id, percentage })
59741
- ),
59742
- annotations: {
59743
- "workers/message": message
59744
- }
59745
- })
59746
- }
59747
- );
59748
- }
59749
- async function patchNonVersionedScriptSettings(complianceConfig, accountId, workerName, settings) {
59750
- const res = await fetchResult(
59751
- complianceConfig,
59752
- `/accounts/${accountId}/workers/scripts/${workerName}/script-settings`,
59753
- {
59754
- method: "PATCH",
59755
- headers: { "Content-Type": "application/json" },
59756
- body: JSON.stringify(settings)
59757
- }
59758
- );
59759
- return res;
59760
- }
59761
- var init_api = __esm({
59762
- "src/versions/api.ts"() {
59763
- init_import_meta_url();
59764
- init_cfetch();
59765
- __name(fetchVersion, "fetchVersion");
59766
- __name(fetchVersions, "fetchVersions");
59767
- __name(fetchLatestDeployments, "fetchLatestDeployments");
59768
- __name(fetchLatestDeployment, "fetchLatestDeployment");
59769
- __name(fetchDeploymentVersions, "fetchDeploymentVersions");
59770
- __name(fetchDeployableVersions, "fetchDeployableVersions");
59771
- __name(createDeployment, "createDeployment");
59772
- __name(patchNonVersionedScriptSettings, "patchNonVersionedScriptSettings");
59773
- }
59774
- });
59775
-
59776
- // ../cli/args.ts
59777
- var processArgument;
59778
- var init_args = __esm({
59779
- "../cli/args.ts"() {
59780
- init_import_meta_url();
59781
- init_interactive();
59782
- processArgument = /* @__PURE__ */ __name(async (args, name2, promptConfig) => {
59783
- const value = args[name2];
59784
- const result = await inputPrompt({
59785
- ...promptConfig,
59786
- // Accept the default value if the arg is already set
59787
- acceptDefault: promptConfig.acceptDefault ?? value !== void 0,
59788
- defaultValue: value ?? promptConfig.defaultValue
59789
- });
59790
- args[name2] = result;
59791
- return result;
59792
- }, "processArgument");
59793
- }
59794
- });
59795
-
59796
59705
  // src/core/helpers.ts
59797
59706
  function demandOneOfOption(...options) {
59798
59707
  return function(argv) {
@@ -60518,15 +60427,16 @@ function parseImageName(value) {
60518
60427
  }
60519
60428
  return { name: name2, tag, digest };
60520
60429
  }
60521
- function handleFailure(command2, cb2) {
60430
+ function handleFailure(command2, cb2, scope) {
60522
60431
  return async (args) => {
60523
60432
  try {
60524
60433
  if (!args.json) {
60525
60434
  await printWranglerBanner();
60526
- logger.warn(constructStatusMessage(command2, "alpha"));
60435
+ const commandStatus = command2.includes("cloudchamber") ? "alpha" : "open-beta";
60436
+ logger.warn(constructStatusMessage(command2, commandStatus));
60527
60437
  }
60528
60438
  const config = readConfig(args);
60529
- await fillOpenAPIConfiguration(config, args.json);
60439
+ await fillOpenAPIConfiguration(config, args.json, scope);
60530
60440
  await cb2(args, config);
60531
60441
  } catch (err) {
60532
60442
  if (!args.json || !isNonInteractiveOrCI()) {
@@ -60547,10 +60457,10 @@ function handleFailure(command2, cb2) {
60547
60457
  async function loadAccountSpinner({ json }) {
60548
60458
  await promiseSpinner(loadAccount(), { message: "Loading account", json });
60549
60459
  }
60550
- async function getAPIUrl(config) {
60460
+ async function getAPIUrl(config, accountId, scope) {
60551
60461
  const api = getCloudflareApiBaseUrl(config);
60552
- const accountId = config.account_id || await getAccountId(config);
60553
- return `${api}/accounts/${accountId}/cloudchamber`;
60462
+ const endpoint = scope === cloudchamberScope ? "cloudchamber" : "containers";
60463
+ return `${api}/accounts/${accountId}/${endpoint}`;
60554
60464
  }
60555
60465
  async function promiseSpinner(promise, {
60556
60466
  json = false,
@@ -60571,73 +60481,21 @@ async function promiseSpinner(promise, {
60571
60481
  stop();
60572
60482
  return t7;
60573
60483
  }
60574
- async function fillOpenAPIConfiguration(config, json) {
60484
+ async function fillOpenAPIConfiguration(config, _json2, scope) {
60575
60485
  const headers = OpenAPI.HEADERS !== void 0 ? { ...OpenAPI.HEADERS } : {};
60576
- if (Object.keys(getConfigCache("wrangler-account.json")).length === 0) {
60577
- await wrap2((0, import_promises12.mkdir)("node_modules", {}));
60578
- purgeConfigCaches();
60579
- }
60580
- const scopes = getScopes();
60581
- const needsCloudchamberToken = !scopes?.find(
60582
- (scope) => scope === "cloudchamber:write"
60583
- );
60584
- const cloudchamberScope = ["cloudchamber:write"];
60585
- const scopesToSet = scopes == void 0 ? cloudchamberScope.concat(DefaultScopeKeys) : cloudchamberScope.concat(scopes);
60586
- if (getAuthFromEnv() && needsCloudchamberToken) {
60587
- setLoginScopeKeys(scopesToSet);
60588
- reinitialiseAuthTokens({
60589
- expiration_time: "2300-01-01:00:00:00+00:00",
60590
- oauth_token: "_"
60591
- });
60592
- } else {
60593
- if (needsCloudchamberToken && scopes) {
60594
- logRaw(
60595
- status.warning + " We need to re-authenticate to add a cloudchamber token..."
60596
- );
60597
- await getAccountId(config);
60598
- const account = getAccountFromCache();
60599
- config.account_id = account?.id ?? config.account_id;
60600
- await promiseSpinner(logout(), { json, message: "Revoking token" });
60601
- purgeConfigCaches();
60602
- reinitialiseAuthTokens({});
60603
- }
60604
- setLoginScopeKeys(scopesToSet);
60605
- const [, err2] = await wrap2(requireAuth(config));
60606
- if (err2) {
60607
- throw new UserError(
60608
- `authenticating with the Cloudflare API: ${err2.message}`
60609
- );
60610
- }
60611
- }
60612
- const token = getAPIToken();
60613
- if (!token) {
60614
- throw new UserError("unexpected apiToken not existing in credentials");
60615
- }
60616
- const val2 = "apiToken" in token ? token.apiToken : null;
60617
- if (!val2) {
60618
- throw new UserError(
60619
- "we don't allow for authKey/email credentials, use `wrangler login` or CLOUDFLARE_API_TOKEN env variable to authenticate"
60620
- );
60621
- }
60622
- headers["Authorization"] = `Bearer ${val2}`;
60623
- headers["User-Agent"] = `wrangler/${version}`;
60486
+ const accountId = await requireAuth(config);
60487
+ const auth = requireApiToken();
60488
+ addAuthorizationHeaderIfUnspecified(headers, auth);
60489
+ addUserAgent(headers);
60624
60490
  OpenAPI.CREDENTIALS = "omit";
60625
60491
  if (OpenAPI.BASE.length === 0) {
60626
- const [base, errApiURL] = await wrap2(getAPIUrl(config));
60492
+ const [base, errApiURL] = await wrap2(getAPIUrl(config, accountId, scope));
60627
60493
  if (errApiURL) {
60628
60494
  throw new UserError("getting the API url: " + errApiURL.message);
60629
60495
  }
60630
60496
  OpenAPI.BASE = base;
60631
60497
  }
60632
60498
  OpenAPI.HEADERS = headers;
60633
- const [, err] = await wrap2(loadAccountSpinner({ json }));
60634
- if (err) {
60635
- let message = err.message;
60636
- if (json && err instanceof ApiError) {
60637
- message = JSON.stringify(err);
60638
- }
60639
- throw new UserError("Loading account failed: " + message);
60640
- }
60641
60499
  }
60642
60500
  function interactWithUser(config) {
60643
60501
  return !config.json && !isNonInteractiveOrCI();
@@ -60979,18 +60837,16 @@ function cleanForInstanceType(app) {
60979
60837
  delete app.configuration.vcpu;
60980
60838
  return app;
60981
60839
  }
60982
- var import_promises12, imageRe;
60840
+ var cloudchamberScope, imageRe;
60983
60841
  var init_common = __esm({
60984
60842
  "src/cloudchamber/common.ts"() {
60985
60843
  init_import_meta_url();
60986
- import_promises12 = require("fs/promises");
60987
60844
  init_cli();
60988
60845
  init_colors();
60989
60846
  init_interactive();
60990
60847
  init_containers_shared();
60991
- init_package();
60848
+ init_internal();
60992
60849
  init_config2();
60993
- init_config_cache();
60994
60850
  init_CommandRegistry();
60995
60851
  init_misc_variables();
60996
60852
  init_errors();
@@ -61001,6 +60857,7 @@ var init_common = __esm({
61001
60857
  init_parse();
61002
60858
  init_wrap();
61003
60859
  init_locations();
60860
+ cloudchamberScope = "cloudchamber:write";
61004
60861
  imageRe = (() => {
61005
60862
  const alphaNumeric = "[a-z0-9]+";
61006
60863
  const separator = "(?:\\.|_|__|-+)";
@@ -61037,6 +60894,830 @@ var init_common = __esm({
61037
60894
  }
61038
60895
  });
61039
60896
 
60897
+ // src/cloudchamber/build.ts
60898
+ function buildYargs(yargs) {
60899
+ return yargs.positional("PATH", {
60900
+ type: "string",
60901
+ describe: "Path for the directory containing the Dockerfile to build",
60902
+ demandOption: true
60903
+ }).option("tag", {
60904
+ alias: "t",
60905
+ type: "string",
60906
+ demandOption: true,
60907
+ describe: 'Name and optionally a tag (format: "name:tag")'
60908
+ }).option("path-to-docker", {
60909
+ type: "string",
60910
+ default: "docker",
60911
+ describe: "Path to your docker binary if it's not on $PATH",
60912
+ demandOption: false
60913
+ }).option("push", {
60914
+ alias: "p",
60915
+ type: "boolean",
60916
+ describe: "Push the built image to Cloudflare's managed registry",
60917
+ default: false
60918
+ }).option("platform", {
60919
+ type: "string",
60920
+ default: "linux/amd64",
60921
+ describe: "Platform to build for. Defaults to the architecture support by Workers (linux/amd64)",
60922
+ demandOption: false
60923
+ });
60924
+ }
60925
+ function pushYargs(yargs) {
60926
+ return yargs.option("path-to-docker", {
60927
+ type: "string",
60928
+ default: "docker",
60929
+ describe: "Path to your docker binary if it's not on $PATH",
60930
+ demandOption: false
60931
+ }).positional("TAG", { type: "string", demandOption: true });
60932
+ }
60933
+ async function buildAndMaybePush(args, pathToDocker, push, containerConfig) {
60934
+ try {
60935
+ const account = await loadAccount();
60936
+ const cloudflareAccountID = account.external_account_id;
60937
+ const imageTag = getCloudflareRegistryWithAccountNamespace(
60938
+ cloudflareAccountID,
60939
+ args.tag
60940
+ );
60941
+ const { buildCmd, dockerfile } = await constructBuildCommand(
60942
+ {
60943
+ tag: imageTag,
60944
+ pathToDockerfile: args.pathToDockerfile,
60945
+ buildContext: args.buildContext,
60946
+ args: args.args,
60947
+ platform: args.platform,
60948
+ setNetworkToHost: Boolean(getCIOverrideNetworkModeHost())
60949
+ },
60950
+ logger
60951
+ );
60952
+ await dockerBuild(pathToDocker, {
60953
+ buildCmd,
60954
+ dockerfile
60955
+ });
60956
+ const inspectOutput = await dockerImageInspect(pathToDocker, {
60957
+ imageTag,
60958
+ formatString: "{{ .Size }} {{ len .RootFS.Layers }}"
60959
+ });
60960
+ const [sizeStr, layerStr] = inspectOutput.split(" ");
60961
+ const size = parseInt(sizeStr, 10);
60962
+ const layers = parseInt(layerStr, 10);
60963
+ const MiB = 1024 * 1024;
60964
+ const requiredSize = Math.ceil(size * 1.1 + layers * 16 * MiB);
60965
+ await ensureDiskLimits({
60966
+ requiredSize,
60967
+ account,
60968
+ containerApp: containerConfig
60969
+ });
60970
+ if (push) {
60971
+ await dockerLoginManagedRegistry(pathToDocker);
60972
+ try {
60973
+ const repositoryOnly = imageTag.split(":")[0];
60974
+ const localDigest = await getDockerImageDigest(pathToDocker, imageTag);
60975
+ const digest = repositoryOnly + "@" + localDigest;
60976
+ await runDockerCmd(
60977
+ pathToDocker,
60978
+ ["manifest", "inspect", digest],
60979
+ "ignore"
60980
+ );
60981
+ logger.log("Image already exists remotely, skipping push");
60982
+ logger.debug(
60983
+ `Untagging built image: ${imageTag} since there was no change.`
60984
+ );
60985
+ await runDockerCmd(pathToDocker, ["image", "rm", imageTag]);
60986
+ return "";
60987
+ } catch (error2) {
60988
+ logger.log(`Image does not exist remotely, pushing: ${imageTag}`);
60989
+ await runDockerCmd(pathToDocker, ["push", imageTag]);
60990
+ }
60991
+ }
60992
+ return imageTag;
60993
+ } catch (error2) {
60994
+ if (error2 instanceof Error) {
60995
+ throw new UserError(error2.message);
60996
+ }
60997
+ throw new UserError("An unknown error occurred");
60998
+ }
60999
+ }
61000
+ async function buildCommand(args, config) {
61001
+ if ((0, import_fs12.existsSync)(args.PATH) && !isDir(args.PATH)) {
61002
+ throw new UserError(
61003
+ `${args.PATH} is not a directory. Please specify a valid directory path.`
61004
+ );
61005
+ }
61006
+ const containers2 = config.containers ?? [void 0];
61007
+ const pathToDockerfile = (0, import_path8.join)(args.PATH, "Dockerfile");
61008
+ for (const container of containers2) {
61009
+ await buildAndMaybePush(
61010
+ {
61011
+ tag: args.tag,
61012
+ pathToDockerfile,
61013
+ buildContext: args.PATH,
61014
+ platform: args.platform
61015
+ // no option to add env vars at build time...?
61016
+ },
61017
+ getDockerPath() ?? args.pathToDocker,
61018
+ args.push,
61019
+ container
61020
+ );
61021
+ }
61022
+ }
61023
+ async function pushCommand(args, _4) {
61024
+ try {
61025
+ await dockerLoginManagedRegistry(args.pathToDocker);
61026
+ const account = await loadAccount();
61027
+ const newTag = getCloudflareRegistryWithAccountNamespace(
61028
+ account.external_account_id,
61029
+ args.TAG
61030
+ );
61031
+ const dockerPath = args.pathToDocker ?? getDockerPath();
61032
+ await runDockerCmd(dockerPath, ["tag", args.TAG, newTag]);
61033
+ await runDockerCmd(dockerPath, ["push", newTag]);
61034
+ logger.log(`Pushed image: ${newTag}`);
61035
+ } catch (error2) {
61036
+ if (error2 instanceof Error) {
61037
+ throw new UserError(error2.message);
61038
+ }
61039
+ throw new UserError("An unknown error occurred");
61040
+ }
61041
+ }
61042
+ async function ensureDiskLimits(options) {
61043
+ const MB = 1e3 * 1e3;
61044
+ const MiB = 1024 * 1024;
61045
+ const appDiskSize = resolveAppDiskSize(options.account, options.containerApp);
61046
+ const accountDiskSize = (options.account.limits.disk_mb_per_deployment ?? 2e3) * MB;
61047
+ if (appDiskSize && appDiskSize > accountDiskSize) {
61048
+ throw new UserError(
61049
+ `Exceeded account limits: Your container is configured to use a disk size of ${appDiskSize / MB} MB. However, that exceeds the account limit of ${accountDiskSize / MB}`
61050
+ );
61051
+ }
61052
+ const maxAllowedImageSizeBytes = appDiskSize ?? accountDiskSize;
61053
+ logger.debug(
61054
+ `Disk size limits when building the container: appDiskSize:${appDiskSize}, accountDiskSize:${accountDiskSize}, maxAllowedImageSizeBytes=${maxAllowedImageSizeBytes}(${maxAllowedImageSizeBytes / MB} MB), requiredSized=${options.requiredSize}(${Math.ceil(options.requiredSize / MiB)}MiB)`
61055
+ );
61056
+ if (maxAllowedImageSizeBytes < options.requiredSize) {
61057
+ throw new UserError(
61058
+ `Image too large: needs ${Math.ceil(options.requiredSize / 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.`
61059
+ );
61060
+ }
61061
+ }
61062
+ var import_fs12, import_path8;
61063
+ var init_build2 = __esm({
61064
+ "src/cloudchamber/build.ts"() {
61065
+ init_import_meta_url();
61066
+ import_fs12 = require("fs");
61067
+ import_path8 = require("path");
61068
+ init_containers_shared();
61069
+ init_misc_variables();
61070
+ init_errors();
61071
+ init_logger();
61072
+ init_common();
61073
+ init_locations();
61074
+ __name(buildYargs, "buildYargs");
61075
+ __name(pushYargs, "pushYargs");
61076
+ __name(buildAndMaybePush, "buildAndMaybePush");
61077
+ __name(buildCommand, "buildCommand");
61078
+ __name(pushCommand, "pushCommand");
61079
+ __name(ensureDiskLimits, "ensureDiskLimits");
61080
+ }
61081
+ });
61082
+
61083
+ // src/cloudchamber/images/list.ts
61084
+ function deleteImageYargs(yargs) {
61085
+ return yargs.positional("image", {
61086
+ type: "string",
61087
+ description: "image to delete",
61088
+ demandOption: true
61089
+ });
61090
+ }
61091
+ function listImagesYargs(yargs) {
61092
+ return yargs.option("filter", {
61093
+ type: "string",
61094
+ description: "Regex to filter results"
61095
+ });
61096
+ }
61097
+ async function handleDeleteImageCommand(args, _config) {
61098
+ try {
61099
+ if (!args.image.includes(":")) {
61100
+ throw new Error(`Must provide a tag to delete`);
61101
+ }
61102
+ return await promiseSpinner(
61103
+ getCreds().then(async (creds) => {
61104
+ const url4 = new URL(`https://${getCloudflareContainerRegistry()}`);
61105
+ const baseUrl = `${url4.protocol}//${url4.host}`;
61106
+ const [image, tag] = args.image.split(":");
61107
+ await deleteTag(baseUrl, image, tag, creds);
61108
+ const gcUrl = `${baseUrl}/v2/gc/layers`;
61109
+ const gcResponse = await fetch(gcUrl, {
61110
+ method: "PUT",
61111
+ headers: {
61112
+ Authorization: `Basic ${creds}`,
61113
+ "Content-Type": "application/json"
61114
+ }
61115
+ });
61116
+ if (!gcResponse.ok) {
61117
+ throw new Error(
61118
+ `Failed to delete image ${args.image}: ${gcResponse.status} ${gcResponse.statusText}`
61119
+ );
61120
+ }
61121
+ await logger.log(`Deleted tag: ${args.image}`);
61122
+ }),
61123
+ { message: "Deleting", json: args.json }
61124
+ );
61125
+ } catch (error2) {
61126
+ logger.log(`Error when removing image: ${error2}`);
61127
+ }
61128
+ }
61129
+ async function handleListImagesCommand(args, _config) {
61130
+ try {
61131
+ return await promiseSpinner(
61132
+ getCreds().then(async (creds) => {
61133
+ const repos = await listRepos(creds);
61134
+ const tags = [];
61135
+ for (const repo of repos) {
61136
+ const stripped = repo.replace(/^\/+/, "");
61137
+ const regex2 = new RegExp(args.filter ?? "");
61138
+ if (regex2.test(stripped)) {
61139
+ const repoTags = await listTags(stripped, creds);
61140
+ tags.push({ name: stripped, tags: repoTags });
61141
+ }
61142
+ }
61143
+ await ListTags(tags, false, args.json);
61144
+ }),
61145
+ { message: "Listing", json: args.json }
61146
+ );
61147
+ } catch (error2) {
61148
+ logger.log(`Error listing images: ${error2}`);
61149
+ }
61150
+ }
61151
+ async function ListTags(responses, digests = false, json = false) {
61152
+ if (!digests) {
61153
+ responses = responses.map((resp) => {
61154
+ return {
61155
+ name: resp.name,
61156
+ tags: resp.tags.filter((t7) => !t7.startsWith("sha256"))
61157
+ };
61158
+ });
61159
+ }
61160
+ responses = responses.filter((resp) => {
61161
+ return resp.tags !== void 0 && resp.tags.length != 0;
61162
+ });
61163
+ if (json) {
61164
+ logger.log(JSON.stringify(responses, null, 2));
61165
+ } else {
61166
+ const rows = responses.map((resp) => {
61167
+ return {
61168
+ REPOSITORY: resp.name,
61169
+ TAG: resp.tags.join(" ")
61170
+ };
61171
+ }).flat();
61172
+ logger.table(rows);
61173
+ }
61174
+ }
61175
+ async function listTags(repo, creds) {
61176
+ const url4 = new URL(`https://${getCloudflareContainerRegistry()}`);
61177
+ const baseUrl = `${url4.protocol}//${url4.host}`;
61178
+ const tagsUrl = `${baseUrl}/v2/${repo}/tags/list`;
61179
+ const tagsResponse = await fetch(tagsUrl, {
61180
+ method: "GET",
61181
+ headers: {
61182
+ Authorization: `Basic ${creds}`
61183
+ }
61184
+ });
61185
+ const tagsData = await tagsResponse.json();
61186
+ return tagsData.tags || [];
61187
+ }
61188
+ async function listRepos(creds) {
61189
+ const url4 = new URL(`https://${getCloudflareContainerRegistry()}`);
61190
+ const catalogUrl = `${url4.protocol}//${url4.host}/v2/_catalog`;
61191
+ const response = await fetch(catalogUrl, {
61192
+ method: "GET",
61193
+ headers: {
61194
+ Authorization: `Basic ${creds}`
61195
+ }
61196
+ });
61197
+ if (!response.ok) {
61198
+ console.log(JSON.stringify(response));
61199
+ throw new Error(
61200
+ `Failed to fetch repository catalog: ${response.status} ${response.statusText}`
61201
+ );
61202
+ }
61203
+ const data = await response.json();
61204
+ return data.repositories || [];
61205
+ }
61206
+ async function deleteTag(baseUrl, image, tag, creds) {
61207
+ const manifestAcceptHeader = "application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json";
61208
+ const manifestUrl = `${baseUrl}/v2/${image}/manifests/${tag}`;
61209
+ const headResponse = await fetch(manifestUrl, {
61210
+ method: "HEAD",
61211
+ headers: {
61212
+ Authorization: `Basic ${creds}`,
61213
+ Accept: manifestAcceptHeader
61214
+ }
61215
+ });
61216
+ if (!headResponse.ok) {
61217
+ throw new Error(
61218
+ `failed to retrieve tag info for ${tag}: ${headResponse.status} ${headResponse.statusText}`
61219
+ );
61220
+ }
61221
+ const digest = headResponse.headers.get("Docker-Content-Digest");
61222
+ if (!digest) {
61223
+ throw new Error(`Digest not found for tag "${tag}".`);
61224
+ }
61225
+ const deleteUrl = `${baseUrl}/v2/${image}/manifests/${tag}`;
61226
+ const deleteResponse = await fetch(deleteUrl, {
61227
+ method: "DELETE",
61228
+ headers: {
61229
+ Authorization: `Basic ${creds}`,
61230
+ Accept: manifestAcceptHeader
61231
+ }
61232
+ });
61233
+ if (!deleteResponse.ok) {
61234
+ throw new Error(
61235
+ `Failed to delete tag "${tag}" (digest: ${digest}): ${deleteResponse.status} ${deleteResponse.statusText}`
61236
+ );
61237
+ }
61238
+ }
61239
+ async function getCreds() {
61240
+ return await ImageRegistriesService.generateImageRegistryCredentials(
61241
+ getCloudflareContainerRegistry(),
61242
+ {
61243
+ expiration_minutes: 5,
61244
+ permissions: ["pull", "push"]
61245
+ }
61246
+ ).then(async (credentials) => {
61247
+ return Buffer.from(`v1:${credentials.password}`).toString("base64");
61248
+ });
61249
+ }
61250
+ var imagesCommand;
61251
+ var init_list = __esm({
61252
+ "src/cloudchamber/images/list.ts"() {
61253
+ init_import_meta_url();
61254
+ init_containers_shared();
61255
+ init_logger();
61256
+ init_common();
61257
+ imagesCommand = /* @__PURE__ */ __name((yargs, scope) => {
61258
+ return yargs.command(
61259
+ "list",
61260
+ "perform operations on images in your Cloudflare managed registry",
61261
+ (args) => listImagesYargs(args),
61262
+ (args) => handleFailure(
61263
+ `wrangler containers images list`,
61264
+ async (_args, config) => {
61265
+ await handleListImagesCommand(args, config);
61266
+ },
61267
+ scope
61268
+ )(args)
61269
+ ).command(
61270
+ "delete [image]",
61271
+ "remove an image from your Cloudflare managed registry",
61272
+ (args) => deleteImageYargs(args),
61273
+ (args) => handleFailure(
61274
+ `wrangler containers images delete`,
61275
+ async (_args, config) => {
61276
+ await handleDeleteImageCommand(args, config);
61277
+ },
61278
+ scope
61279
+ )(args)
61280
+ );
61281
+ }, "imagesCommand");
61282
+ __name(deleteImageYargs, "deleteImageYargs");
61283
+ __name(listImagesYargs, "listImagesYargs");
61284
+ __name(handleDeleteImageCommand, "handleDeleteImageCommand");
61285
+ __name(handleListImagesCommand, "handleListImagesCommand");
61286
+ __name(ListTags, "ListTags");
61287
+ __name(listTags, "listTags");
61288
+ __name(listRepos, "listRepos");
61289
+ __name(deleteTag, "deleteTag");
61290
+ __name(getCreds, "getCreds");
61291
+ }
61292
+ });
61293
+
61294
+ // ../cli/args.ts
61295
+ var processArgument;
61296
+ var init_args = __esm({
61297
+ "../cli/args.ts"() {
61298
+ init_import_meta_url();
61299
+ init_interactive();
61300
+ processArgument = /* @__PURE__ */ __name(async (args, name2, promptConfig) => {
61301
+ const value = args[name2];
61302
+ const result = await inputPrompt({
61303
+ ...promptConfig,
61304
+ // Accept the default value if the arg is already set
61305
+ acceptDefault: promptConfig.acceptDefault ?? value !== void 0,
61306
+ defaultValue: value ?? promptConfig.defaultValue
61307
+ });
61308
+ args[name2] = result;
61309
+ return result;
61310
+ }, "processArgument");
61311
+ }
61312
+ });
61313
+
61314
+ // src/containers/containers.ts
61315
+ function deleteYargs(args) {
61316
+ return args.positional("ID", {
61317
+ describe: "id of the containers to delete",
61318
+ type: "string"
61319
+ });
61320
+ }
61321
+ async function deleteCommand(deleteArgs, _config) {
61322
+ if (!deleteArgs.ID) {
61323
+ throw new Error(
61324
+ "You must provide an ID. Use 'wrangler containers list` to view your containers."
61325
+ );
61326
+ }
61327
+ if (deleteArgs.json) {
61328
+ const container = await ApplicationsService.deleteApplication(
61329
+ deleteArgs.ID
61330
+ );
61331
+ console.log(JSON.stringify(container, null, 4));
61332
+ return;
61333
+ }
61334
+ startSection("Delete your container");
61335
+ if (isInteractive2()) {
61336
+ const yes = await inputPrompt({
61337
+ question: "Are you sure that you want to delete these containers? The associated DO container will lose access to the containers.",
61338
+ type: "confirm",
61339
+ label: ""
61340
+ });
61341
+ if (!yes) {
61342
+ cancel("The operation has been cancelled");
61343
+ return;
61344
+ }
61345
+ }
61346
+ const [, err] = await wrap2(
61347
+ ApplicationsService.deleteApplication(deleteArgs.ID)
61348
+ );
61349
+ if (err) {
61350
+ if (err instanceof ApiError) {
61351
+ if (err.status === 400 || err.status === 404) {
61352
+ throw new UserError(
61353
+ `There has been an error deleting the container.
61354
+ ${err.body.error}`
61355
+ );
61356
+ }
61357
+ throw new Error(
61358
+ `There has been an unknown error deleting the container.
61359
+ ${JSON.stringify(err.body)}`
61360
+ );
61361
+ }
61362
+ throw new Error(
61363
+ `There has been an internal error deleting your containers.
61364
+ ${err.message}`
61365
+ );
61366
+ }
61367
+ endSection("Your container has been deleted");
61368
+ }
61369
+ function infoYargs(args) {
61370
+ return args.positional("ID", {
61371
+ describe: "id of the containers to view",
61372
+ type: "string"
61373
+ });
61374
+ }
61375
+ async function infoCommand(infoArgs, _config) {
61376
+ if (!infoArgs.ID) {
61377
+ throw new Error(
61378
+ "You must provide an ID. Use 'wrangler containers list` to view your containers."
61379
+ );
61380
+ }
61381
+ if (infoArgs.json || !isInteractive2()) {
61382
+ const application2 = ApplicationsService.getApplication(infoArgs.ID);
61383
+ console.log(JSON.stringify(application2, null, 4));
61384
+ return;
61385
+ }
61386
+ await loadAccountSpinner(infoArgs);
61387
+ const [application, err] = await wrap2(
61388
+ ApplicationsService.getApplication(infoArgs.ID)
61389
+ );
61390
+ if (err) {
61391
+ throw new UserError(
61392
+ `There has been an internal error requesting your containers.
61393
+ ${err.message}`
61394
+ );
61395
+ }
61396
+ const details = flatDetails(application);
61397
+ const applicationDetails = {
61398
+ label: `${application.name} (${application.created_at})`,
61399
+ details,
61400
+ value: application.id
61401
+ };
61402
+ await inputPrompt({
61403
+ type: "list",
61404
+ question: "Container",
61405
+ options: [applicationDetails],
61406
+ label: "Exiting"
61407
+ });
61408
+ }
61409
+ function listYargs(args) {
61410
+ return args;
61411
+ }
61412
+ async function listCommand(listArgs, config) {
61413
+ if (listArgs.json || !isInteractive2()) {
61414
+ const applications = await ApplicationsService.listApplications();
61415
+ console.log(JSON.stringify(applications, null, 4));
61416
+ return;
61417
+ }
61418
+ await listCommandHandle(listArgs, config);
61419
+ }
61420
+ function flatDetails(obj, indentLevel = 0) {
61421
+ const indent = " ".repeat(indentLevel);
61422
+ return Object.entries(obj).reduce((acc, [key, value]) => {
61423
+ if (value !== void 0 && value !== null && typeof value === "object" && !Array.isArray(value)) {
61424
+ acc.push(`${indent}${key}:`);
61425
+ acc.push(
61426
+ ...flatDetails(value, indentLevel + 1)
61427
+ );
61428
+ } else if (value !== void 0) {
61429
+ acc.push(`${indent}${key}: ${value}`);
61430
+ }
61431
+ return acc;
61432
+ }, []);
61433
+ }
61434
+ async function listCommandHandle(_args, _config) {
61435
+ const keepListIter = true;
61436
+ while (keepListIter) {
61437
+ logRaw(gray(shapes.bar));
61438
+ const { start, stop } = spinner();
61439
+ start("Loading Containers");
61440
+ const [applications, err] = await wrap2(
61441
+ ApplicationsService.listApplications()
61442
+ );
61443
+ stop();
61444
+ if (err) {
61445
+ throw new UserError(
61446
+ `There has been an internal error listing your containers.
61447
+ ${err.message}`
61448
+ );
61449
+ }
61450
+ if (applications === void 0 || applications === null || applications.length === 0) {
61451
+ logRaw(
61452
+ "No containers found. See https://dash.cloudflare.com/?to=/:account/workers/containers to learn more."
61453
+ );
61454
+ return;
61455
+ }
61456
+ const applicationDetails = /* @__PURE__ */ __name((a5) => {
61457
+ const details = flatDetails(a5);
61458
+ return {
61459
+ label: `${a5.name} (${a5.created_at})`,
61460
+ details,
61461
+ value: a5.id
61462
+ };
61463
+ }, "applicationDetails");
61464
+ const application = await listContainersAndChoose(applications);
61465
+ let refresh = false;
61466
+ await inputPrompt({
61467
+ type: "list",
61468
+ question: "Containers",
61469
+ helpText: "Hit enter to return to your containers or 'r' to refresh",
61470
+ options: [applicationDetails(application)],
61471
+ label: "going back",
61472
+ onRefresh: /* @__PURE__ */ __name(async () => {
61473
+ start("Refreshing application");
61474
+ const app = await ApplicationsService.getApplication(application.id);
61475
+ if (refresh) {
61476
+ return [];
61477
+ }
61478
+ stop();
61479
+ if (app) {
61480
+ const details = applicationDetails(app);
61481
+ details.label += ", last refresh: " + (/* @__PURE__ */ new Date()).toLocaleString();
61482
+ return [details];
61483
+ }
61484
+ return app;
61485
+ }, "onRefresh")
61486
+ });
61487
+ refresh = true;
61488
+ stop();
61489
+ }
61490
+ }
61491
+ async function listContainersAndChoose(applications) {
61492
+ const getLabels = /* @__PURE__ */ __name((a5) => {
61493
+ const labels = a5.configuration.labels ?? [];
61494
+ if (!labels || labels.length == 0) {
61495
+ return [];
61496
+ }
61497
+ const out = labels.map((l6) => ` ${dim(l6.name)}: ${dim(l6.value)}`);
61498
+ return `Labels:
61499
+ ` + out.join(",\n");
61500
+ }, "getLabels");
61501
+ const application = await processArgument({}, "applicationId", {
61502
+ type: "list",
61503
+ question: "Your Containers",
61504
+ helpText: "Get more information by selecting a container with the enter/return key",
61505
+ options: applications.map((i5) => ({
61506
+ label: i5.name,
61507
+ value: i5.id,
61508
+ details: [
61509
+ `Id: ${dim(`${i5.id}`)}`,
61510
+ `Instances: ${dim(`${i5.instances}`)}`,
61511
+ `Image: ${dim(i5.configuration.image)}`,
61512
+ ...getLabels(i5) ?? []
61513
+ ]
61514
+ })),
61515
+ label: "container"
61516
+ });
61517
+ return applications.find((a5) => a5.id === application);
61518
+ }
61519
+ var init_containers = __esm({
61520
+ "src/containers/containers.ts"() {
61521
+ init_import_meta_url();
61522
+ init_cli();
61523
+ init_args();
61524
+ init_colors();
61525
+ init_interactive();
61526
+ init_containers_shared();
61527
+ init_common();
61528
+ init_wrap();
61529
+ init_errors();
61530
+ init_is_interactive();
61531
+ __name(deleteYargs, "deleteYargs");
61532
+ __name(deleteCommand, "deleteCommand");
61533
+ __name(infoYargs, "infoYargs");
61534
+ __name(infoCommand, "infoCommand");
61535
+ __name(listYargs, "listYargs");
61536
+ __name(listCommand, "listCommand");
61537
+ __name(flatDetails, "flatDetails");
61538
+ __name(listCommandHandle, "listCommandHandle");
61539
+ __name(listContainersAndChoose, "listContainersAndChoose");
61540
+ }
61541
+ });
61542
+
61543
+ // src/containers/index.ts
61544
+ var containersScope, containers;
61545
+ var init_containers2 = __esm({
61546
+ "src/containers/index.ts"() {
61547
+ init_import_meta_url();
61548
+ init_build2();
61549
+ init_common();
61550
+ init_list();
61551
+ init_containers();
61552
+ containersScope = "containers:write";
61553
+ containers = /* @__PURE__ */ __name((yargs, subHelp) => {
61554
+ return yargs.command(
61555
+ "build [PATH]",
61556
+ "build a dockerfile",
61557
+ (args) => buildYargs(args),
61558
+ (args) => handleFailure(
61559
+ `wrangler containers build`,
61560
+ buildCommand,
61561
+ containersScope
61562
+ )(args)
61563
+ ).command(
61564
+ "push [TAG]",
61565
+ "push a tagged image to a Cloudflare managed registry, which is automatically integrated with your account",
61566
+ (args) => pushYargs(args),
61567
+ (args) => handleFailure(
61568
+ `wrangler containers push`,
61569
+ pushCommand,
61570
+ containersScope
61571
+ )(args)
61572
+ ).command(
61573
+ "images",
61574
+ "perform operations on images in your Cloudflare managed registry",
61575
+ (args) => imagesCommand(args, containersScope).command(subHelp)
61576
+ ).command(
61577
+ "info [ID]",
61578
+ "get information about a specific container",
61579
+ (args) => infoYargs(args),
61580
+ (args) => handleFailure(
61581
+ `wrangler containers info`,
61582
+ infoCommand,
61583
+ containersScope
61584
+ )(args)
61585
+ ).command(
61586
+ "list",
61587
+ "list containers",
61588
+ (args) => listYargs(args),
61589
+ (args) => handleFailure(
61590
+ `wrangler containers list`,
61591
+ listCommand,
61592
+ containersScope
61593
+ )(args)
61594
+ ).command(
61595
+ "delete [ID]",
61596
+ "delete a container",
61597
+ (args) => deleteYargs(args),
61598
+ (args) => handleFailure(
61599
+ `wrangler containers delete`,
61600
+ deleteCommand,
61601
+ containersScope
61602
+ )(args)
61603
+ );
61604
+ }, "containers");
61605
+ }
61606
+ });
61607
+
61608
+ // src/versions/api.ts
61609
+ async function fetchVersion(complianceConfig, accountId, workerName, versionId, versionCache) {
61610
+ const cachedVersion = versionCache?.get(versionId);
61611
+ if (cachedVersion) {
61612
+ return cachedVersion;
61613
+ }
61614
+ const version5 = await fetchResult(
61615
+ complianceConfig,
61616
+ `/accounts/${accountId}/workers/scripts/${workerName}/versions/${versionId}`
61617
+ );
61618
+ versionCache?.set(version5.id, version5);
61619
+ return version5;
61620
+ }
61621
+ async function fetchVersions(complianceConfig, accountId, workerName, versionCache, ...versionIds) {
61622
+ return Promise.all(
61623
+ versionIds.map(
61624
+ (versionId) => fetchVersion(
61625
+ complianceConfig,
61626
+ accountId,
61627
+ workerName,
61628
+ versionId,
61629
+ versionCache
61630
+ )
61631
+ )
61632
+ );
61633
+ }
61634
+ async function fetchLatestDeployments(complianceConfig, accountId, workerName) {
61635
+ const { deployments } = await fetchResult(
61636
+ complianceConfig,
61637
+ `/accounts/${accountId}/workers/scripts/${workerName}/deployments`
61638
+ );
61639
+ return deployments;
61640
+ }
61641
+ async function fetchLatestDeployment(complianceConfig, accountId, workerName) {
61642
+ const deployments = await fetchLatestDeployments(
61643
+ complianceConfig,
61644
+ accountId,
61645
+ workerName
61646
+ );
61647
+ return deployments.at(0);
61648
+ }
61649
+ async function fetchDeploymentVersions(complianceConfig, accountId, workerName, deployment, versionCache) {
61650
+ if (!deployment) {
61651
+ return [[], /* @__PURE__ */ new Map()];
61652
+ }
61653
+ const versionTraffic = new Map(
61654
+ deployment.versions.map((v7) => [v7.version_id, v7.percentage])
61655
+ );
61656
+ const versions2 = await fetchVersions(
61657
+ complianceConfig,
61658
+ accountId,
61659
+ workerName,
61660
+ versionCache,
61661
+ ...versionTraffic.keys()
61662
+ );
61663
+ return [versions2, versionTraffic];
61664
+ }
61665
+ async function fetchDeployableVersions(complianceConfig, accountId, workerName, versionCache) {
61666
+ const { items: versions2 } = await fetchResult(
61667
+ complianceConfig,
61668
+ `/accounts/${accountId}/workers/scripts/${workerName}/versions?deployable=true`
61669
+ );
61670
+ for (const version5 of versions2) {
61671
+ versionCache.set(version5.id, version5);
61672
+ }
61673
+ return versions2;
61674
+ }
61675
+ async function createDeployment(complianceConfig, accountId, workerName, versionTraffic, message, force) {
61676
+ return await fetchResult(
61677
+ complianceConfig,
61678
+ `/accounts/${accountId}/workers/scripts/${workerName}/deployments${force ? "?force=true" : ""}`,
61679
+ {
61680
+ method: "POST",
61681
+ headers: { "Content-Type": "application/json" },
61682
+ body: JSON.stringify({
61683
+ strategy: "percentage",
61684
+ versions: Array.from(versionTraffic).map(
61685
+ ([version_id, percentage]) => ({ version_id, percentage })
61686
+ ),
61687
+ annotations: {
61688
+ "workers/message": message
61689
+ }
61690
+ })
61691
+ }
61692
+ );
61693
+ }
61694
+ async function patchNonVersionedScriptSettings(complianceConfig, accountId, workerName, settings) {
61695
+ const res = await fetchResult(
61696
+ complianceConfig,
61697
+ `/accounts/${accountId}/workers/scripts/${workerName}/script-settings`,
61698
+ {
61699
+ method: "PATCH",
61700
+ headers: { "Content-Type": "application/json" },
61701
+ body: JSON.stringify(settings)
61702
+ }
61703
+ );
61704
+ return res;
61705
+ }
61706
+ var init_api = __esm({
61707
+ "src/versions/api.ts"() {
61708
+ init_import_meta_url();
61709
+ init_cfetch();
61710
+ __name(fetchVersion, "fetchVersion");
61711
+ __name(fetchVersions, "fetchVersions");
61712
+ __name(fetchLatestDeployments, "fetchLatestDeployments");
61713
+ __name(fetchLatestDeployment, "fetchLatestDeployment");
61714
+ __name(fetchDeploymentVersions, "fetchDeploymentVersions");
61715
+ __name(fetchDeployableVersions, "fetchDeployableVersions");
61716
+ __name(createDeployment, "createDeployment");
61717
+ __name(patchNonVersionedScriptSettings, "patchNonVersionedScriptSettings");
61718
+ }
61719
+ });
61720
+
61040
61721
  // src/cloudchamber/helpers/diff.ts
61041
61722
  function buildValues(diff, lastComponent, newString, oldString, useLongestToken) {
61042
61723
  const components = [];
@@ -61844,192 +62525,6 @@ var init_apply = __esm({
61844
62525
  }
61845
62526
  });
61846
62527
 
61847
- // src/cloudchamber/build.ts
61848
- function buildYargs(yargs) {
61849
- return yargs.positional("PATH", {
61850
- type: "string",
61851
- describe: "Path for the directory containing the Dockerfile to build",
61852
- demandOption: true
61853
- }).option("tag", {
61854
- alias: "t",
61855
- type: "string",
61856
- demandOption: true,
61857
- describe: 'Name and optionally a tag (format: "name:tag")'
61858
- }).option("path-to-docker", {
61859
- type: "string",
61860
- default: "docker",
61861
- describe: "Path to your docker binary if it's not on $PATH",
61862
- demandOption: false
61863
- }).option("push", {
61864
- alias: "p",
61865
- type: "boolean",
61866
- describe: "Push the built image to Cloudflare's managed registry",
61867
- default: false
61868
- }).option("platform", {
61869
- type: "string",
61870
- default: "linux/amd64",
61871
- describe: "Platform to build for. Defaults to the architecture support by Workers (linux/amd64)",
61872
- demandOption: false
61873
- });
61874
- }
61875
- function pushYargs(yargs) {
61876
- return yargs.option("path-to-docker", {
61877
- type: "string",
61878
- default: "docker",
61879
- describe: "Path to your docker binary if it's not on $PATH",
61880
- demandOption: false
61881
- }).positional("TAG", { type: "string", demandOption: true });
61882
- }
61883
- async function buildAndMaybePush(args, pathToDocker, push, containerConfig) {
61884
- try {
61885
- const account = await loadAccount();
61886
- const cloudflareAccountID = account.external_account_id;
61887
- const imageTag = getCloudflareRegistryWithAccountNamespace(
61888
- cloudflareAccountID,
61889
- args.tag
61890
- );
61891
- const { buildCmd, dockerfile } = await constructBuildCommand(
61892
- {
61893
- tag: imageTag,
61894
- pathToDockerfile: args.pathToDockerfile,
61895
- buildContext: args.buildContext,
61896
- args: args.args,
61897
- platform: args.platform,
61898
- setNetworkToHost: Boolean(getCIOverrideNetworkModeHost())
61899
- },
61900
- logger
61901
- );
61902
- await dockerBuild(pathToDocker, {
61903
- buildCmd,
61904
- dockerfile
61905
- });
61906
- const inspectOutput = await dockerImageInspect(pathToDocker, {
61907
- imageTag,
61908
- formatString: "{{ .Size }} {{ len .RootFS.Layers }}"
61909
- });
61910
- const [sizeStr, layerStr] = inspectOutput.split(" ");
61911
- const size = parseInt(sizeStr, 10);
61912
- const layers = parseInt(layerStr, 10);
61913
- const MiB = 1024 * 1024;
61914
- const requiredSize = Math.ceil(size * 1.1 + layers * 16 * MiB);
61915
- await ensureDiskLimits({
61916
- requiredSize,
61917
- account,
61918
- containerApp: containerConfig
61919
- });
61920
- if (push) {
61921
- await dockerLoginManagedRegistry(pathToDocker);
61922
- try {
61923
- const repositoryOnly = imageTag.split(":")[0];
61924
- const localDigest = await getDockerImageDigest(pathToDocker, imageTag);
61925
- const digest = repositoryOnly + "@" + localDigest;
61926
- await runDockerCmd(
61927
- pathToDocker,
61928
- ["manifest", "inspect", digest],
61929
- "ignore"
61930
- );
61931
- logger.log("Image already exists remotely, skipping push");
61932
- logger.debug(
61933
- `Untagging built image: ${imageTag} since there was no change.`
61934
- );
61935
- await runDockerCmd(pathToDocker, ["image", "rm", imageTag]);
61936
- return "";
61937
- } catch (error2) {
61938
- logger.log(`Image does not exist remotely, pushing: ${imageTag}`);
61939
- await runDockerCmd(pathToDocker, ["push", imageTag]);
61940
- }
61941
- }
61942
- return imageTag;
61943
- } catch (error2) {
61944
- if (error2 instanceof Error) {
61945
- throw new UserError(error2.message);
61946
- }
61947
- throw new UserError("An unknown error occurred");
61948
- }
61949
- }
61950
- async function buildCommand(args, config) {
61951
- if ((0, import_fs12.existsSync)(args.PATH) && !isDir(args.PATH)) {
61952
- throw new UserError(
61953
- `${args.PATH} is not a directory. Please specify a valid directory path.`
61954
- );
61955
- }
61956
- const containers2 = config.containers ?? [void 0];
61957
- const pathToDockerfile = (0, import_path8.join)(args.PATH, "Dockerfile");
61958
- for (const container of containers2) {
61959
- await buildAndMaybePush(
61960
- {
61961
- tag: args.tag,
61962
- pathToDockerfile,
61963
- buildContext: args.PATH,
61964
- platform: args.platform
61965
- // no option to add env vars at build time...?
61966
- },
61967
- getDockerPath() ?? args.pathToDocker,
61968
- args.push,
61969
- container
61970
- );
61971
- }
61972
- }
61973
- async function pushCommand(args, _4) {
61974
- try {
61975
- await dockerLoginManagedRegistry(args.pathToDocker);
61976
- const account = await loadAccount();
61977
- const newTag = getCloudflareRegistryWithAccountNamespace(
61978
- account.external_account_id,
61979
- args.TAG
61980
- );
61981
- const dockerPath = args.pathToDocker ?? getDockerPath();
61982
- await runDockerCmd(dockerPath, ["tag", args.TAG, newTag]);
61983
- await runDockerCmd(dockerPath, ["push", newTag]);
61984
- logger.log(`Pushed image: ${newTag}`);
61985
- } catch (error2) {
61986
- if (error2 instanceof Error) {
61987
- throw new UserError(error2.message);
61988
- }
61989
- throw new UserError("An unknown error occurred");
61990
- }
61991
- }
61992
- async function ensureDiskLimits(options) {
61993
- const MB = 1e3 * 1e3;
61994
- const MiB = 1024 * 1024;
61995
- const appDiskSize = resolveAppDiskSize(options.account, options.containerApp);
61996
- const accountDiskSize = (options.account.limits.disk_mb_per_deployment ?? 2e3) * MB;
61997
- if (appDiskSize && appDiskSize > accountDiskSize) {
61998
- throw new UserError(
61999
- `Exceeded account limits: Your container is configured to use a disk size of ${appDiskSize / MB} MB. However, that exceeds the account limit of ${accountDiskSize / MB}`
62000
- );
62001
- }
62002
- const maxAllowedImageSizeBytes = appDiskSize ?? accountDiskSize;
62003
- logger.debug(
62004
- `Disk size limits when building the container: appDiskSize:${appDiskSize}, accountDiskSize:${accountDiskSize}, maxAllowedImageSizeBytes=${maxAllowedImageSizeBytes}(${maxAllowedImageSizeBytes / MB} MB), requiredSized=${options.requiredSize}(${Math.ceil(options.requiredSize / MiB)}MiB)`
62005
- );
62006
- if (maxAllowedImageSizeBytes < options.requiredSize) {
62007
- throw new UserError(
62008
- `Image too large: needs ${Math.ceil(options.requiredSize / 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.`
62009
- );
62010
- }
62011
- }
62012
- var import_fs12, import_path8;
62013
- var init_build2 = __esm({
62014
- "src/cloudchamber/build.ts"() {
62015
- init_import_meta_url();
62016
- import_fs12 = require("fs");
62017
- import_path8 = require("path");
62018
- init_containers_shared();
62019
- init_misc_variables();
62020
- init_errors();
62021
- init_logger();
62022
- init_common();
62023
- init_locations();
62024
- __name(buildYargs, "buildYargs");
62025
- __name(pushYargs, "pushYargs");
62026
- __name(buildAndMaybePush, "buildAndMaybePush");
62027
- __name(buildCommand, "buildCommand");
62028
- __name(pushCommand, "pushCommand");
62029
- __name(ensureDiskLimits, "ensureDiskLimits");
62030
- }
62031
- });
62032
-
62033
62528
  // src/cloudchamber/deploy.ts
62034
62529
  async function maybeBuildContainer(containerConfig, imageTag, dryRun, pathToDocker) {
62035
62530
  try {
@@ -62059,7 +62554,11 @@ async function deployContainers(config, { versionId, accountId, scriptName, dryR
62059
62554
  return;
62060
62555
  }
62061
62556
  if (!dryRun) {
62062
- await fillOpenAPIConfiguration(config, isNonInteractiveOrCI());
62557
+ await fillOpenAPIConfiguration(
62558
+ config,
62559
+ isNonInteractiveOrCI(),
62560
+ containersScope
62561
+ );
62063
62562
  }
62064
62563
  const pathToDocker = getDockerPath();
62065
62564
  for (const container of config.containers) {
@@ -62116,6 +62615,7 @@ var init_deploy = __esm({
62116
62615
  "src/cloudchamber/deploy.ts"() {
62117
62616
  init_import_meta_url();
62118
62617
  init_containers_shared();
62618
+ init_containers2();
62119
62619
  init_misc_variables();
62120
62620
  init_errors();
62121
62621
  init_is_interactive();
@@ -62230,7 +62730,7 @@ var init_create = __esm({
62230
62730
 
62231
62731
  // src/d1/list.ts
62232
62732
  var d1ListCommand, listDatabases;
62233
- var init_list = __esm({
62733
+ var init_list2 = __esm({
62234
62734
  "src/d1/list.ts"() {
62235
62735
  init_import_meta_url();
62236
62736
  init_cfetch();
@@ -62325,7 +62825,7 @@ var init_utils3 = __esm({
62325
62825
  init_cfetch();
62326
62826
  init_errors();
62327
62827
  init_constants4();
62328
- init_list();
62828
+ init_list2();
62329
62829
  __name(getDatabaseInfoFromConfig, "getDatabaseInfoFromConfig");
62330
62830
  getDatabaseByNameOrBinding = /* @__PURE__ */ __name(async (config, accountId, name2) => {
62331
62831
  const dbFromConfig = getDatabaseInfoFromConfig(config, name2);
@@ -65179,7 +65679,7 @@ var init_bindings = __esm({
65179
65679
  import_node_assert10 = __toESM(require("assert"));
65180
65680
  init_cfetch();
65181
65681
  init_create();
65182
- init_list();
65682
+ init_list2();
65183
65683
  init_utils3();
65184
65684
  init_dialogs();
65185
65685
  init_errors();
@@ -67343,7 +67843,7 @@ var init_xxhash_wasm = __esm({
67343
67843
 
67344
67844
  // src/sites.ts
67345
67845
  async function* getFilesInFolder(dirPath) {
67346
- const files = await (0, import_promises13.readdir)(dirPath, { withFileTypes: true });
67846
+ const files = await (0, import_promises12.readdir)(dirPath, { withFileTypes: true });
67347
67847
  for (const file of files) {
67348
67848
  if (ALWAYS_IGNORE.has(file.name)) {
67349
67849
  continue;
@@ -67440,7 +67940,7 @@ async function syncWorkersSite(complianceConfig, accountId, scriptName, siteAsse
67440
67940
  if (!include(assetFile) || exclude2(assetFile)) {
67441
67941
  continue;
67442
67942
  }
67443
- const content = await (0, import_promises13.readFile)(absAssetFile, "base64");
67943
+ const content = await (0, import_promises12.readFile)(absAssetFile, "base64");
67444
67944
  const assetSize = Buffer.byteLength(content);
67445
67945
  await validateAssetSize(absAssetFile, assetFile);
67446
67946
  const assetKey = hashAsset(hasher, assetFile, content);
@@ -67495,7 +67995,7 @@ async function syncWorkersSite(complianceConfig, accountId, scriptName, siteAsse
67495
67995
  for (const [absAssetFile, assetKey] of nextBucket) {
67496
67996
  bucket.push({
67497
67997
  key: assetKey,
67498
- value: await (0, import_promises13.readFile)(absAssetFile, "base64"),
67998
+ value: await (0, import_promises12.readFile)(absAssetFile, "base64"),
67499
67999
  base64: true
67500
68000
  });
67501
68001
  if (controller.signal.aborted) {
@@ -67579,7 +68079,7 @@ async function syncWorkersSite(complianceConfig, accountId, scriptName, siteAsse
67579
68079
  return { manifest, namespace };
67580
68080
  }
67581
68081
  async function validateAssetSize(absFilePath, relativeFilePath) {
67582
- const { size } = await (0, import_promises13.stat)(absFilePath);
68082
+ const { size } = await (0, import_promises12.stat)(absFilePath);
67583
68083
  if (size > 25 * 1024 * 1024) {
67584
68084
  throw new UserError(
67585
68085
  `File ${relativeFilePath} is too big, it should be under 25 MiB. See https://developers.cloudflare.com/workers/platform/limits#kv-limits`
@@ -67610,12 +68110,12 @@ function getSiteAssetPaths(config, assetDirectory, includePatterns = config.site
67610
68110
  return void 0;
67611
68111
  }
67612
68112
  }
67613
- var import_node_assert15, import_promises13, path26, ALWAYS_IGNORE, HIDDEN_FILES_TO_INCLUDE, MAX_DIFF_LINES2, MAX_BUCKET_SIZE2, MAX_BUCKET_KEYS, MAX_BATCH_OPERATIONS;
68113
+ var import_node_assert15, import_promises12, path26, ALWAYS_IGNORE, HIDDEN_FILES_TO_INCLUDE, MAX_DIFF_LINES2, MAX_BUCKET_SIZE2, MAX_BUCKET_KEYS, MAX_BATCH_OPERATIONS;
67614
68114
  var init_sites = __esm({
67615
68115
  "src/sites.ts"() {
67616
68116
  init_import_meta_url();
67617
68117
  import_node_assert15 = __toESM(require("assert"));
67618
- import_promises13 = require("fs/promises");
68118
+ import_promises12 = require("fs/promises");
67619
68119
  path26 = __toESM(require("path"));
67620
68120
  init_workers_shared();
67621
68121
  init_source();
@@ -67788,7 +68288,7 @@ async function retryOnAPIFailure(action, backoff = 0, attempts = MAX_ATTEMPTS) {
67788
68288
  if (attempts <= 1) {
67789
68289
  throw err;
67790
68290
  }
67791
- await (0, import_promises14.setTimeout)(backoff);
68291
+ await (0, import_promises13.setTimeout)(backoff);
67792
68292
  return retryOnAPIFailure(
67793
68293
  action,
67794
68294
  backoff + (MAX_ATTEMPTS - attempts) * 1e3,
@@ -67796,11 +68296,11 @@ async function retryOnAPIFailure(action, backoff = 0, attempts = MAX_ATTEMPTS) {
67796
68296
  );
67797
68297
  }
67798
68298
  }
67799
- var import_promises14, MAX_ATTEMPTS;
68299
+ var import_promises13, MAX_ATTEMPTS;
67800
68300
  var init_retry = __esm({
67801
68301
  "src/utils/retry.ts"() {
67802
68302
  init_import_meta_url();
67803
- import_promises14 = require("timers/promises");
68303
+ import_promises13 = require("timers/promises");
67804
68304
  init_source();
67805
68305
  init_logger();
67806
68306
  init_parse();
@@ -76475,7 +76975,7 @@ function createSSHPublicKeyOptionalYargs(yargs) {
76475
76975
  }
76476
76976
  async function retrieveSSHKey(sshKeyPath, { json } = { json: false }) {
76477
76977
  try {
76478
- const file = (await (0, import_promises15.readFile)(sshKeyPath)).toString();
76978
+ const file = (await (0, import_promises14.readFile)(sshKeyPath)).toString();
76479
76979
  validatePublicSSHKeyCLI(file, { json });
76480
76980
  return file;
76481
76981
  } catch (err) {
@@ -76516,10 +77016,10 @@ async function tryToRetrieveAllDefaultSSHKeyPaths() {
76516
77016
  const path71 = `${HOME}/.ssh`;
76517
77017
  const paths = [];
76518
77018
  try {
76519
- const dirList = await (0, import_promises15.readdir)(path71);
77019
+ const dirList = await (0, import_promises14.readdir)(path71);
76520
77020
  for (const file of dirList) {
76521
77021
  if (file.endsWith(".pub")) {
76522
- const s5 = await (0, import_promises15.stat)(`${path71}/${file}`);
77022
+ const s5 = await (0, import_promises14.stat)(`${path71}/${file}`);
76523
77023
  if (s5.isFile()) {
76524
77024
  paths.push(`${path71}/${file}`);
76525
77025
  }
@@ -76558,7 +77058,7 @@ async function shouldPromptForNewSSHKeyAppear(keys = void 0) {
76558
77058
  }
76559
77059
  let foundValidSSHKeyThatDontExist = false;
76560
77060
  for (const defaultSSHKeyPath of defaultSSHKeyPaths) {
76561
- const file = (await (0, import_promises15.readFile)(defaultSSHKeyPath)).toString().trim();
77061
+ const file = (await (0, import_promises14.readFile)(defaultSSHKeyPath)).toString().trim();
76562
77062
  try {
76563
77063
  validateSSHKey(file);
76564
77064
  } catch {
@@ -76671,11 +77171,11 @@ async function promptForSSHKey(args) {
76671
77171
  }
76672
77172
  return res;
76673
77173
  }
76674
- var import_promises15, import_os4, sshCommand;
77174
+ var import_promises14, import_os4, sshCommand;
76675
77175
  var init_ssh = __esm({
76676
77176
  "src/cloudchamber/ssh/ssh.ts"() {
76677
77177
  init_import_meta_url();
76678
- import_promises15 = require("fs/promises");
77178
+ import_promises14 = require("fs/promises");
76679
77179
  import_os4 = require("os");
76680
77180
  init_cli();
76681
77181
  init_colors();
@@ -76690,7 +77190,7 @@ var init_ssh = __esm({
76690
77190
  __name(createSSHPublicKeyOptionalYargs, "createSSHPublicKeyOptionalYargs");
76691
77191
  __name(retrieveSSHKey, "retrieveSSHKey");
76692
77192
  __name(sshPrompts, "sshPrompts");
76693
- sshCommand = /* @__PURE__ */ __name((yargs) => {
77193
+ sshCommand = /* @__PURE__ */ __name((yargs, scope) => {
76694
77194
  return yargs.command(
76695
77195
  "list",
76696
77196
  "list the ssh keys added to your account",
@@ -76704,7 +77204,8 @@ var init_ssh = __esm({
76704
77204
  return;
76705
77205
  }
76706
77206
  await handleListSSHKeysCommand(sshArgs, config);
76707
- }
77207
+ },
77208
+ scope
76708
77209
  )(args)
76709
77210
  ).command(
76710
77211
  "create",
@@ -76728,7 +77229,8 @@ var init_ssh = __esm({
76728
77229
  return;
76729
77230
  }
76730
77231
  await handleCreateSSHPublicKeyCommand(sshArgs);
76731
- }
77232
+ },
77233
+ scope
76732
77234
  )(args)
76733
77235
  );
76734
77236
  }, "sshCommand");
@@ -77364,7 +77866,7 @@ function deleteCommandOptionalYargs(yargs) {
77364
77866
  describe: "deployment you want to delete"
77365
77867
  });
77366
77868
  }
77367
- async function deleteCommand(deleteArgs, config) {
77869
+ async function deleteCommand2(deleteArgs, config) {
77368
77870
  await loadAccountSpinner(deleteArgs);
77369
77871
  if (!interactWithUser(deleteArgs)) {
77370
77872
  if (!deleteArgs.deploymentId) {
@@ -77415,7 +77917,7 @@ var init_delete = __esm({
77415
77917
  init_common();
77416
77918
  init_wrap();
77417
77919
  __name(deleteCommandOptionalYargs, "deleteCommandOptionalYargs");
77418
- __name(deleteCommand, "deleteCommand");
77920
+ __name(deleteCommand2, "deleteCommand");
77419
77921
  __name(handleDeleteCommand, "handleDeleteCommand");
77420
77922
  }
77421
77923
  });
@@ -77528,7 +78030,7 @@ var init_images2 = __esm({
77528
78030
  init_common();
77529
78031
  init_wrap();
77530
78032
  __name(configureImageRegistryOptionalYargs, "configureImageRegistryOptionalYargs");
77531
- registriesCommand = /* @__PURE__ */ __name((yargs) => {
78033
+ registriesCommand = /* @__PURE__ */ __name((yargs, scope) => {
77532
78034
  return yargs.command(
77533
78035
  "configure",
77534
78036
  "Configure Cloudchamber to pull from specific registries",
@@ -77551,7 +78053,8 @@ var init_images2 = __esm({
77551
78053
  return;
77552
78054
  }
77553
78055
  await handleConfigureImageRegistryCommand(args, config);
77554
- }
78056
+ },
78057
+ scope
77555
78058
  )(args)
77556
78059
  ).command(
77557
78060
  "credentials [domain]",
@@ -77590,7 +78093,8 @@ var init_images2 = __esm({
77590
78093
  }
77591
78094
  );
77592
78095
  console.log(credentials.password);
77593
- }
78096
+ },
78097
+ scope
77594
78098
  )(args);
77595
78099
  }
77596
78100
  ).command(
@@ -77606,7 +78110,8 @@ var init_images2 = __esm({
77606
78110
  imageArgs.domain
77607
78111
  );
77608
78112
  console.log(JSON.stringify(registry, null, 4));
77609
- }
78113
+ },
78114
+ scope
77610
78115
  )(args);
77611
78116
  }
77612
78117
  ).command(
@@ -77622,7 +78127,8 @@ var init_images2 = __esm({
77622
78127
  return;
77623
78128
  }
77624
78129
  await handleListImageRegistriesCommand(args, config);
77625
- }
78130
+ },
78131
+ scope
77626
78132
  )(args)
77627
78133
  );
77628
78134
  }, "registriesCommand");
@@ -77632,215 +78138,6 @@ var init_images2 = __esm({
77632
78138
  }
77633
78139
  });
77634
78140
 
77635
- // src/cloudchamber/images/list.ts
77636
- function deleteImageYargs(yargs) {
77637
- return yargs.positional("image", {
77638
- type: "string",
77639
- description: "image to delete",
77640
- demandOption: true
77641
- });
77642
- }
77643
- function listImagesYargs(yargs) {
77644
- return yargs.option("filter", {
77645
- type: "string",
77646
- description: "Regex to filter results"
77647
- });
77648
- }
77649
- async function handleDeleteImageCommand(args, _config) {
77650
- try {
77651
- if (!args.image.includes(":")) {
77652
- throw new Error(`Must provide a tag to delete`);
77653
- }
77654
- return await promiseSpinner(
77655
- getCreds().then(async (creds) => {
77656
- const url4 = new URL(`https://${getCloudflareContainerRegistry()}`);
77657
- const baseUrl = `${url4.protocol}//${url4.host}`;
77658
- const [image, tag] = args.image.split(":");
77659
- await deleteTag(baseUrl, image, tag, creds);
77660
- const gcUrl = `${baseUrl}/v2/gc/layers`;
77661
- const gcResponse = await fetch(gcUrl, {
77662
- method: "PUT",
77663
- headers: {
77664
- Authorization: `Basic ${creds}`,
77665
- "Content-Type": "application/json"
77666
- }
77667
- });
77668
- if (!gcResponse.ok) {
77669
- throw new Error(
77670
- `Failed to delete image ${args.image}: ${gcResponse.status} ${gcResponse.statusText}`
77671
- );
77672
- }
77673
- await logger.log(`Deleted tag: ${args.image}`);
77674
- }),
77675
- { message: "Deleting", json: args.json }
77676
- );
77677
- } catch (error2) {
77678
- logger.log(`Error when removing image: ${error2}`);
77679
- }
77680
- }
77681
- async function handleListImagesCommand(args, _config) {
77682
- try {
77683
- return await promiseSpinner(
77684
- getCreds().then(async (creds) => {
77685
- const repos = await listRepos(creds);
77686
- const tags = [];
77687
- for (const repo of repos) {
77688
- const stripped = repo.replace(/^\/+/, "");
77689
- const regex2 = new RegExp(args.filter ?? "");
77690
- if (regex2.test(stripped)) {
77691
- const repoTags = await listTags(stripped, creds);
77692
- tags.push({ name: stripped, tags: repoTags });
77693
- }
77694
- }
77695
- await ListTags(tags, false, args.json);
77696
- }),
77697
- { message: "Listing", json: args.json }
77698
- );
77699
- } catch (error2) {
77700
- logger.log(`Error listing images: ${error2}`);
77701
- }
77702
- }
77703
- async function ListTags(responses, digests = false, json = false) {
77704
- if (!digests) {
77705
- responses = responses.map((resp) => {
77706
- return {
77707
- name: resp.name,
77708
- tags: resp.tags.filter((t7) => !t7.startsWith("sha256"))
77709
- };
77710
- });
77711
- }
77712
- responses = responses.filter((resp) => {
77713
- return resp.tags !== void 0 && resp.tags.length != 0;
77714
- });
77715
- if (json) {
77716
- logger.log(JSON.stringify(responses, null, 2));
77717
- } else {
77718
- const rows = responses.map((resp) => {
77719
- return {
77720
- REPOSITORY: resp.name,
77721
- TAG: resp.tags.join(" ")
77722
- };
77723
- }).flat();
77724
- logger.table(rows);
77725
- }
77726
- }
77727
- async function listTags(repo, creds) {
77728
- const url4 = new URL(`https://${getCloudflareContainerRegistry()}`);
77729
- const baseUrl = `${url4.protocol}//${url4.host}`;
77730
- const tagsUrl = `${baseUrl}/v2/${repo}/tags/list`;
77731
- const tagsResponse = await fetch(tagsUrl, {
77732
- method: "GET",
77733
- headers: {
77734
- Authorization: `Basic ${creds}`
77735
- }
77736
- });
77737
- const tagsData = await tagsResponse.json();
77738
- return tagsData.tags || [];
77739
- }
77740
- async function listRepos(creds) {
77741
- const url4 = new URL(`https://${getCloudflareContainerRegistry()}`);
77742
- const catalogUrl = `${url4.protocol}//${url4.host}/v2/_catalog`;
77743
- const response = await fetch(catalogUrl, {
77744
- method: "GET",
77745
- headers: {
77746
- Authorization: `Basic ${creds}`
77747
- }
77748
- });
77749
- if (!response.ok) {
77750
- console.log(JSON.stringify(response));
77751
- throw new Error(
77752
- `Failed to fetch repository catalog: ${response.status} ${response.statusText}`
77753
- );
77754
- }
77755
- const data = await response.json();
77756
- return data.repositories || [];
77757
- }
77758
- async function deleteTag(baseUrl, image, tag, creds) {
77759
- const manifestAcceptHeader = "application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json";
77760
- const manifestUrl = `${baseUrl}/v2/${image}/manifests/${tag}`;
77761
- const headResponse = await fetch(manifestUrl, {
77762
- method: "HEAD",
77763
- headers: {
77764
- Authorization: `Basic ${creds}`,
77765
- Accept: manifestAcceptHeader
77766
- }
77767
- });
77768
- if (!headResponse.ok) {
77769
- throw new Error(
77770
- `failed to retrieve tag info for ${tag}: ${headResponse.status} ${headResponse.statusText}`
77771
- );
77772
- }
77773
- const digest = headResponse.headers.get("Docker-Content-Digest");
77774
- if (!digest) {
77775
- throw new Error(`Digest not found for tag "${tag}".`);
77776
- }
77777
- const deleteUrl = `${baseUrl}/v2/${image}/manifests/${tag}`;
77778
- const deleteResponse = await fetch(deleteUrl, {
77779
- method: "DELETE",
77780
- headers: {
77781
- Authorization: `Basic ${creds}`,
77782
- Accept: manifestAcceptHeader
77783
- }
77784
- });
77785
- if (!deleteResponse.ok) {
77786
- throw new Error(
77787
- `Failed to delete tag "${tag}" (digest: ${digest}): ${deleteResponse.status} ${deleteResponse.statusText}`
77788
- );
77789
- }
77790
- }
77791
- async function getCreds() {
77792
- return await ImageRegistriesService.generateImageRegistryCredentials(
77793
- getCloudflareContainerRegistry(),
77794
- {
77795
- expiration_minutes: 5,
77796
- permissions: ["pull", "push"]
77797
- }
77798
- ).then(async (credentials) => {
77799
- return Buffer.from(`v1:${credentials.password}`).toString("base64");
77800
- });
77801
- }
77802
- var imagesCommand;
77803
- var init_list2 = __esm({
77804
- "src/cloudchamber/images/list.ts"() {
77805
- init_import_meta_url();
77806
- init_containers_shared();
77807
- init_logger();
77808
- init_common();
77809
- imagesCommand = /* @__PURE__ */ __name((yargs) => {
77810
- return yargs.command(
77811
- "list",
77812
- "perform operations on images in your Cloudflare managed registry",
77813
- (args) => listImagesYargs(args),
77814
- (args) => handleFailure(
77815
- `wrangler containers images list`,
77816
- async (_args, config) => {
77817
- await handleListImagesCommand(args, config);
77818
- }
77819
- )(args)
77820
- ).command(
77821
- "delete [image]",
77822
- "remove an image from your Cloudflare managed registry",
77823
- (args) => deleteImageYargs(args),
77824
- (args) => handleFailure(
77825
- `wrangler containers images delete`,
77826
- async (_args, config) => {
77827
- await handleDeleteImageCommand(args, config);
77828
- }
77829
- )(args)
77830
- );
77831
- }, "imagesCommand");
77832
- __name(deleteImageYargs, "deleteImageYargs");
77833
- __name(listImagesYargs, "listImagesYargs");
77834
- __name(handleDeleteImageCommand, "handleDeleteImageCommand");
77835
- __name(handleListImagesCommand, "handleListImagesCommand");
77836
- __name(ListTags, "ListTags");
77837
- __name(listTags, "listTags");
77838
- __name(listRepos, "listRepos");
77839
- __name(deleteTag, "deleteTag");
77840
- __name(getCreds, "getCreds");
77841
- }
77842
- });
77843
-
77844
78141
  // src/cloudchamber/list.ts
77845
78142
  function listDeploymentsYargs(args) {
77846
78143
  return args.option("location", {
@@ -77874,7 +78171,7 @@ function listDeploymentsYargs(args) {
77874
78171
  type: "string"
77875
78172
  });
77876
78173
  }
77877
- async function listCommand(deploymentArgs, config) {
78174
+ async function listCommand2(deploymentArgs, config) {
77878
78175
  await loadAccountSpinner(deploymentArgs);
77879
78176
  const prefix = deploymentArgs.deploymentIdPrefix ?? "";
77880
78177
  if (deploymentArgs.json || !isInteractive2()) {
@@ -77905,7 +78202,7 @@ async function listCommand(deploymentArgs, config) {
77905
78202
  console.log(JSON.stringify(deployments, null, 4));
77906
78203
  return;
77907
78204
  }
77908
- await listCommandHandle(prefix, deploymentArgs, config);
78205
+ await listCommandHandle2(prefix, deploymentArgs, config);
77909
78206
  }
77910
78207
  function eventMessage(event, lastEvent) {
77911
78208
  let { message } = event;
@@ -77925,7 +78222,7 @@ function eventMessage(event, lastEvent) {
77925
78222
  }
77926
78223
  return `${message} (${event.time})`;
77927
78224
  }
77928
- var listCommandHandle;
78225
+ var listCommandHandle2;
77929
78226
  var init_list3 = __esm({
77930
78227
  "src/cloudchamber/list.ts"() {
77931
78228
  init_import_meta_url();
@@ -77938,9 +78235,9 @@ var init_list3 = __esm({
77938
78235
  init_util();
77939
78236
  init_common();
77940
78237
  __name(listDeploymentsYargs, "listDeploymentsYargs");
77941
- __name(listCommand, "listCommand");
78238
+ __name(listCommand2, "listCommand");
77942
78239
  __name(eventMessage, "eventMessage");
77943
- listCommandHandle = /* @__PURE__ */ __name(async (deploymentIdPrefix, args, _config) => {
78240
+ listCommandHandle2 = /* @__PURE__ */ __name(async (deploymentIdPrefix, args, _config) => {
77944
78241
  const keepListIter = true;
77945
78242
  while (keepListIter) {
77946
78243
  logRaw(gray(shapes.bar));
@@ -78259,7 +78556,7 @@ var init_cloudchamber = __esm({
78259
78556
  init_curl();
78260
78557
  init_delete();
78261
78558
  init_images2();
78262
- init_list2();
78559
+ init_list();
78263
78560
  init_list3();
78264
78561
  init_modify();
78265
78562
  init_ssh();
@@ -78270,334 +78567,91 @@ var init_cloudchamber = __esm({
78270
78567
  "delete [deploymentId]",
78271
78568
  "Delete an existing deployment that is running in the Cloudflare edge",
78272
78569
  (args) => deleteCommandOptionalYargs(args),
78273
- (args) => handleFailure(`wrangler cloudchamber delete`, deleteCommand)(args)
78570
+ (args) => handleFailure(
78571
+ `wrangler cloudchamber delete`,
78572
+ deleteCommand2,
78573
+ cloudchamberScope
78574
+ )(args)
78274
78575
  ).command(
78275
78576
  "create",
78276
78577
  "Create a new deployment",
78277
78578
  (args) => createCommandOptionalYargs(args),
78278
- (args) => handleFailure(`wrangler cloudchamber create`, createCommand2)(args)
78579
+ (args) => handleFailure(
78580
+ `wrangler cloudchamber create`,
78581
+ createCommand2,
78582
+ cloudchamberScope
78583
+ )(args)
78279
78584
  ).command(
78280
78585
  "list [deploymentIdPrefix]",
78281
78586
  "List and view status of deployments",
78282
78587
  (args) => listDeploymentsYargs(args),
78283
- (args) => handleFailure(`wrangler cloudchamber list`, listCommand)(args)
78588
+ (args) => handleFailure(
78589
+ `wrangler cloudchamber list`,
78590
+ listCommand2,
78591
+ cloudchamberScope
78592
+ )(args)
78284
78593
  ).command(
78285
78594
  "modify [deploymentId]",
78286
78595
  "Modify an existing deployment",
78287
78596
  (args) => modifyCommandOptionalYargs(args),
78288
- (args) => handleFailure(`wrangler cloudchamber modify`, modifyCommand)(args)
78597
+ (args) => handleFailure(
78598
+ `wrangler cloudchamber modify`,
78599
+ modifyCommand,
78600
+ cloudchamberScope
78601
+ )(args)
78289
78602
  ).command(
78290
78603
  "ssh",
78291
78604
  "Manage the ssh keys of your account",
78292
- (args) => sshCommand(args).command(subHelp)
78605
+ (args) => sshCommand(args, cloudchamberScope).command(subHelp)
78293
78606
  ).command(
78294
78607
  "registries",
78295
78608
  "Configure registries via Cloudchamber",
78296
- (args) => registriesCommand(args).command(subHelp)
78609
+ (args) => registriesCommand(args, cloudchamberScope).command(subHelp)
78297
78610
  ).command(
78298
78611
  "curl <path>",
78299
- "send a request to an arbitrary cloudchamber endpoint",
78612
+ "send a request to an arbitrary Cloudchamber endpoint",
78300
78613
  (args) => yargsCurl(args),
78301
- (args) => handleFailure(`wrangler cloudchamber curl`, curlCommand)(args)
78614
+ (args) => handleFailure(
78615
+ `wrangler cloudchamber curl`,
78616
+ curlCommand,
78617
+ cloudchamberScope
78618
+ )(args)
78302
78619
  ).command(
78303
78620
  "apply",
78304
78621
  "apply the changes in the container applications to deploy",
78305
78622
  (args) => applyCommandOptionalYargs(args),
78306
- (args) => handleFailure(`wrangler cloudchamber apply`, applyCommand)(args)
78623
+ (args) => handleFailure(
78624
+ `wrangler cloudchamber apply`,
78625
+ applyCommand,
78626
+ cloudchamberScope
78627
+ )(args)
78307
78628
  ).command(
78308
78629
  "build [PATH]",
78309
78630
  "build a dockerfile",
78310
78631
  (args) => buildYargs(args),
78311
- (args) => handleFailure(`wrangler cloudchamber build`, buildCommand)(args)
78632
+ (args) => handleFailure(
78633
+ `wrangler cloudchamber build`,
78634
+ buildCommand,
78635
+ cloudchamberScope
78636
+ )(args)
78312
78637
  ).command(
78313
78638
  "push [TAG]",
78314
78639
  "push a tagged image to a Cloudflare managed registry, which is automatically integrated with your account",
78315
78640
  (args) => pushYargs(args),
78316
- (args) => handleFailure(`wrangler cloudchamber push`, pushCommand)(args)
78641
+ (args) => handleFailure(
78642
+ `wrangler cloudchamber push`,
78643
+ pushCommand,
78644
+ cloudchamberScope
78645
+ )(args)
78317
78646
  ).command(
78318
78647
  "images",
78319
- "perform operations on images in your clouchamber registry",
78320
- (args) => imagesCommand(args).command(subHelp)
78648
+ "perform operations on images in your Cloudchamber registry",
78649
+ (args) => imagesCommand(args, cloudchamberScope).command(subHelp)
78321
78650
  );
78322
78651
  }, "cloudchamber");
78323
78652
  }
78324
78653
  });
78325
78654
 
78326
- // src/containers/containers.ts
78327
- function deleteYargs(args) {
78328
- return args.positional("ID", {
78329
- describe: "id of the containers to delete",
78330
- type: "string"
78331
- });
78332
- }
78333
- async function deleteCommand2(deleteArgs, _config) {
78334
- await loadAccountSpinner(deleteArgs);
78335
- if (!deleteArgs.ID) {
78336
- throw new Error(
78337
- "You must provide an ID. Use 'wrangler containers list` to view your containers."
78338
- );
78339
- }
78340
- if (deleteArgs.json) {
78341
- const container = await ApplicationsService.deleteApplication(
78342
- deleteArgs.ID
78343
- );
78344
- console.log(JSON.stringify(container, null, 4));
78345
- return;
78346
- }
78347
- startSection("Delete your container");
78348
- if (isInteractive2()) {
78349
- const yes = await inputPrompt({
78350
- question: "Are you sure that you want to delete these containers? The associated DO container will lose access to the containers.",
78351
- type: "confirm",
78352
- label: ""
78353
- });
78354
- if (!yes) {
78355
- cancel("The operation has been cancelled");
78356
- return;
78357
- }
78358
- }
78359
- const [, err] = await wrap2(
78360
- ApplicationsService.deleteApplication(deleteArgs.ID)
78361
- );
78362
- if (err) {
78363
- if (err instanceof ApiError) {
78364
- if (err.status === 400 || err.status === 404) {
78365
- const body = JSON.parse(err.body);
78366
- throw new UserError(
78367
- `There has been an error deleting the container.
78368
- ${body.error}`
78369
- );
78370
- }
78371
- throw new Error(
78372
- `There has been an unknown error deleting the container.
78373
- ${JSON.stringify(err.body)}`
78374
- );
78375
- }
78376
- throw new Error(
78377
- `There has been an internal error deleting your containers.
78378
- ${err.message}`
78379
- );
78380
- }
78381
- endSection("Your container has been deleted");
78382
- }
78383
- function infoYargs(args) {
78384
- return args.positional("ID", {
78385
- describe: "id of the containers to view",
78386
- type: "string"
78387
- });
78388
- }
78389
- async function infoCommand(infoArgs, _config) {
78390
- if (!infoArgs.ID) {
78391
- throw new Error(
78392
- "You must provide an ID. Use 'wrangler containers list` to view your containers."
78393
- );
78394
- }
78395
- if (infoArgs.json || !isInteractive2()) {
78396
- const application2 = ApplicationsService.getApplication(infoArgs.ID);
78397
- console.log(JSON.stringify(application2, null, 4));
78398
- return;
78399
- }
78400
- await loadAccountSpinner(infoArgs);
78401
- const [application, err] = await wrap2(
78402
- ApplicationsService.getApplication(infoArgs.ID)
78403
- );
78404
- if (err) {
78405
- throw new UserError(
78406
- `There has been an internal error requesting your containers.
78407
- ${err.message}`
78408
- );
78409
- }
78410
- const details = flatDetails(application);
78411
- const applicationDetails = {
78412
- label: `${application.name} (${application.created_at})`,
78413
- details,
78414
- value: application.id
78415
- };
78416
- await inputPrompt({
78417
- type: "list",
78418
- question: "Container",
78419
- options: [applicationDetails],
78420
- label: "Exiting"
78421
- });
78422
- }
78423
- function listYargs(args) {
78424
- return args;
78425
- }
78426
- async function listCommand2(listArgs, config) {
78427
- if (listArgs.json || !isInteractive2()) {
78428
- const applications = await ApplicationsService.listApplications();
78429
- console.log(JSON.stringify(applications, null, 4));
78430
- return;
78431
- }
78432
- await listCommandHandle2(listArgs, config);
78433
- }
78434
- function flatDetails(obj, indentLevel = 0) {
78435
- const indent = " ".repeat(indentLevel);
78436
- return Object.entries(obj).reduce((acc, [key, value]) => {
78437
- if (value !== void 0 && value !== null && typeof value === "object" && !Array.isArray(value)) {
78438
- acc.push(`${indent}${key}:`);
78439
- acc.push(
78440
- ...flatDetails(value, indentLevel + 1)
78441
- );
78442
- } else if (value !== void 0) {
78443
- acc.push(`${indent}${key}: ${value}`);
78444
- }
78445
- return acc;
78446
- }, []);
78447
- }
78448
- async function listCommandHandle2(_args, _config) {
78449
- const keepListIter = true;
78450
- while (keepListIter) {
78451
- logRaw(gray(shapes.bar));
78452
- const { start, stop } = spinner();
78453
- start("Loading Containers");
78454
- const [applications, err] = await wrap2(
78455
- ApplicationsService.listApplications()
78456
- );
78457
- stop();
78458
- if (err) {
78459
- throw new UserError(
78460
- `There has been an internal error listing your containers.
78461
- ${err.message}`
78462
- );
78463
- }
78464
- if (applications === void 0 || applications === null || applications.length === 0) {
78465
- logRaw(
78466
- "No containers found. See https://dash.cloudflare.com/?to=/:account/workers/containers to learn more."
78467
- );
78468
- return;
78469
- }
78470
- const applicationDetails = /* @__PURE__ */ __name((a5) => {
78471
- const details = flatDetails(a5);
78472
- return {
78473
- label: `${a5.name} (${a5.created_at})`,
78474
- details,
78475
- value: a5.id
78476
- };
78477
- }, "applicationDetails");
78478
- const application = await listContainersAndChoose(applications);
78479
- let refresh = false;
78480
- await inputPrompt({
78481
- type: "list",
78482
- question: "Containers",
78483
- helpText: "Hit enter to return to your containers or 'r' to refresh",
78484
- options: [applicationDetails(application)],
78485
- label: "going back",
78486
- onRefresh: /* @__PURE__ */ __name(async () => {
78487
- start("Refreshing application");
78488
- const app = await ApplicationsService.getApplication(application.id);
78489
- if (refresh) {
78490
- return [];
78491
- }
78492
- stop();
78493
- if (app) {
78494
- const details = applicationDetails(app);
78495
- details.label += ", last refresh: " + (/* @__PURE__ */ new Date()).toLocaleString();
78496
- return [details];
78497
- }
78498
- return app;
78499
- }, "onRefresh")
78500
- });
78501
- refresh = true;
78502
- stop();
78503
- }
78504
- }
78505
- async function listContainersAndChoose(applications) {
78506
- const getLabels = /* @__PURE__ */ __name((a5) => {
78507
- const labels = a5.configuration.labels ?? [];
78508
- if (!labels || labels.length == 0) {
78509
- return [];
78510
- }
78511
- const out = labels.map((l6) => ` ${dim(l6.name)}: ${dim(l6.value)}`);
78512
- return `Labels:
78513
- ` + out.join(",\n");
78514
- }, "getLabels");
78515
- const application = await processArgument({}, "applicationId", {
78516
- type: "list",
78517
- question: "Your Containers",
78518
- helpText: "Get more information by selecting a container with the enter/return key",
78519
- options: applications.map((i5) => ({
78520
- label: i5.name,
78521
- value: i5.id,
78522
- details: [
78523
- `Id: ${dim(`${i5.id}`)}`,
78524
- `Instances: ${dim(`${i5.instances}`)}`,
78525
- `Image: ${dim(i5.configuration.image)}`,
78526
- ...getLabels(i5) ?? []
78527
- ]
78528
- })),
78529
- label: "container"
78530
- });
78531
- return applications.find((a5) => a5.id === application);
78532
- }
78533
- var init_containers = __esm({
78534
- "src/containers/containers.ts"() {
78535
- init_import_meta_url();
78536
- init_cli();
78537
- init_args();
78538
- init_colors();
78539
- init_interactive();
78540
- init_containers_shared();
78541
- init_common();
78542
- init_wrap();
78543
- init_errors();
78544
- init_is_interactive();
78545
- __name(deleteYargs, "deleteYargs");
78546
- __name(deleteCommand2, "deleteCommand");
78547
- __name(infoYargs, "infoYargs");
78548
- __name(infoCommand, "infoCommand");
78549
- __name(listYargs, "listYargs");
78550
- __name(listCommand2, "listCommand");
78551
- __name(flatDetails, "flatDetails");
78552
- __name(listCommandHandle2, "listCommandHandle");
78553
- __name(listContainersAndChoose, "listContainersAndChoose");
78554
- }
78555
- });
78556
-
78557
- // src/containers/index.ts
78558
- var containers;
78559
- var init_containers2 = __esm({
78560
- "src/containers/index.ts"() {
78561
- init_import_meta_url();
78562
- init_build2();
78563
- init_common();
78564
- init_list2();
78565
- init_containers();
78566
- containers = /* @__PURE__ */ __name((yargs, subHelp) => {
78567
- return yargs.command(
78568
- "build [PATH]",
78569
- "build a dockerfile",
78570
- (args) => buildYargs(args),
78571
- (args) => handleFailure(`wrangler containers build`, buildCommand)(args)
78572
- ).command(
78573
- "push [TAG]",
78574
- "push a tagged image to a Cloudflare managed registry, which is automatically integrated with your account",
78575
- (args) => pushYargs(args),
78576
- (args) => handleFailure(`wrangler containers push`, pushCommand)(args)
78577
- ).command(
78578
- "images",
78579
- "perform operations on images in your Cloudflare managed registry",
78580
- (args) => imagesCommand(args).command(subHelp)
78581
- ).command(
78582
- "info [ID]",
78583
- "get information about a specific container",
78584
- (args) => infoYargs(args),
78585
- (args) => handleFailure(`wrangler containers info`, infoCommand)(args)
78586
- ).command(
78587
- "list",
78588
- "list containers",
78589
- (args) => listYargs(args),
78590
- (args) => handleFailure(`wrangler containers list`, listCommand2)(args)
78591
- ).command(
78592
- "delete [ID]",
78593
- "delete a container",
78594
- (args) => deleteYargs(args),
78595
- (args) => handleFailure(`wrangler containers delete`, deleteCommand2)(args)
78596
- );
78597
- }, "containers");
78598
- }
78599
- });
78600
-
78601
78655
  // src/core/index.ts
78602
78656
  var init_core2 = __esm({
78603
78657
  "src/core/index.ts"() {
@@ -79581,7 +79635,7 @@ async function exportLocal(config, name2, output, tables, noSchema, noData) {
79581
79635
  logger.log(`\u{1F300} Exporting SQL to ${output}...`);
79582
79636
  try {
79583
79637
  const dump = await db.prepare(`PRAGMA miniflare_d1_export(?,?,?);`).bind(noSchema, noData, ...tables).raw();
79584
- await import_promises16.default.writeFile(output, dump[0].join("\n"));
79638
+ await import_promises15.default.writeFile(output, dump[0].join("\n"));
79585
79639
  } catch (e7) {
79586
79640
  throw new UserError(e7.message);
79587
79641
  } finally {
@@ -79625,7 +79679,7 @@ async function exportRemotely(config, name2, output, tables, noSchema, noData) {
79625
79679
  `There was an error while downloading from the presigned URL with status code: ${contents.status}`
79626
79680
  );
79627
79681
  }
79628
- await import_promises16.default.writeFile(output, contents.body || "");
79682
+ await import_promises15.default.writeFile(output, contents.body || "");
79629
79683
  }
79630
79684
  });
79631
79685
  logger.log(`\u{1F300} Downloaded to ${output} successfully!`);
@@ -79676,11 +79730,11 @@ async function pollExport(s5, complianceConfig, accountId, db, dumpOptions, curr
79676
79730
  );
79677
79731
  }
79678
79732
  }
79679
- var import_promises16, import_node_path28, import_miniflare13, import_undici11, d1ExportCommand;
79733
+ var import_promises15, import_node_path28, import_miniflare13, import_undici11, d1ExportCommand;
79680
79734
  var init_export = __esm({
79681
79735
  "src/d1/export.ts"() {
79682
79736
  init_import_meta_url();
79683
- import_promises16 = __toESM(require("fs/promises"));
79737
+ import_promises15 = __toESM(require("fs/promises"));
79684
79738
  import_node_path28 = __toESM(require("path"));
79685
79739
  init_interactive();
79686
79740
  init_source();
@@ -83649,11 +83703,11 @@ async function downloadWorker(accountId, workerName) {
83649
83703
  config
83650
83704
  };
83651
83705
  }
83652
- var import_promises17, import_node_path34, import_toml4, init;
83706
+ var import_promises16, import_node_path34, import_toml4, init;
83653
83707
  var init_init = __esm({
83654
83708
  "src/init.ts"() {
83655
83709
  init_import_meta_url();
83656
- import_promises17 = require("fs/promises");
83710
+ import_promises16 = require("fs/promises");
83657
83711
  import_node_path34 = __toESM(require("path"));
83658
83712
  import_toml4 = __toESM(require_toml());
83659
83713
  init_execa();
@@ -83736,12 +83790,12 @@ var init_init = __esm({
83736
83790
  throw err;
83737
83791
  }
83738
83792
  const creationDir = import_node_path34.default.join(process.cwd(), args.fromDash);
83739
- await (0, import_promises17.mkdir)(creationDir, { recursive: true });
83793
+ await (0, import_promises16.mkdir)(creationDir, { recursive: true });
83740
83794
  const { modules, config } = await downloadWorker(
83741
83795
  accountId,
83742
83796
  args.fromDash
83743
83797
  );
83744
- await (0, import_promises17.mkdir)(import_node_path34.default.join(creationDir, "./src"), {
83798
+ await (0, import_promises16.mkdir)(import_node_path34.default.join(creationDir, "./src"), {
83745
83799
  recursive: true
83746
83800
  });
83747
83801
  config.main = `src/${config.main}`;
@@ -83751,12 +83805,12 @@ var init_init = __esm({
83751
83805
  files.map(async (file) => {
83752
83806
  const filepath = import_node_path34.default.join(creationDir, `./src/${file.name}`);
83753
83807
  const directory = (0, import_node_path34.dirname)(filepath);
83754
- await (0, import_promises17.mkdir)(directory, { recursive: true });
83755
- await (0, import_promises17.writeFile)(filepath, file.stream());
83808
+ await (0, import_promises16.mkdir)(directory, { recursive: true });
83809
+ await (0, import_promises16.writeFile)(filepath, file.stream());
83756
83810
  })
83757
83811
  );
83758
83812
  }
83759
- await (0, import_promises17.writeFile)(
83813
+ await (0, import_promises16.writeFile)(
83760
83814
  import_node_path34.default.join(creationDir, "wrangler.toml"),
83761
83815
  import_toml4.default.stringify(config)
83762
83816
  );
@@ -85367,8 +85421,8 @@ function assetsPlugin(buildOutputDirectory) {
85367
85421
  args.resolveDir,
85368
85422
  args.path.slice("assets:".length)
85369
85423
  );
85370
- const exists = await (0, import_promises18.access)(directory).then(() => true).catch(() => false);
85371
- const isDirectory2 = exists && (await (0, import_promises18.lstat)(directory)).isDirectory();
85424
+ const exists = await (0, import_promises17.access)(directory).then(() => true).catch(() => false);
85425
+ const isDirectory2 = exists && (await (0, import_promises17.lstat)(directory)).isDirectory();
85372
85426
  if (!isDirectory2) {
85373
85427
  return {
85374
85428
  errors: [
@@ -85397,11 +85451,11 @@ function assetsPlugin(buildOutputDirectory) {
85397
85451
  "pages-plugins",
85398
85452
  identifier
85399
85453
  );
85400
- await (0, import_promises18.rm)(staticAssetsOutputDirectory, {
85454
+ await (0, import_promises17.rm)(staticAssetsOutputDirectory, {
85401
85455
  force: true,
85402
85456
  recursive: true
85403
85457
  });
85404
- await (0, import_promises18.cp)(args.path, staticAssetsOutputDirectory, {
85458
+ await (0, import_promises17.cp)(args.path, staticAssetsOutputDirectory, {
85405
85459
  force: true,
85406
85460
  recursive: true
85407
85461
  });
@@ -85421,12 +85475,12 @@ function assetsPlugin(buildOutputDirectory) {
85421
85475
  }
85422
85476
  };
85423
85477
  }
85424
- var import_node_crypto7, import_promises18, import_node_path37, import_esbuild3;
85478
+ var import_node_crypto7, import_promises17, import_node_path37, import_esbuild3;
85425
85479
  var init_buildWorker = __esm({
85426
85480
  "src/pages/functions/buildWorker.ts"() {
85427
85481
  init_import_meta_url();
85428
85482
  import_node_crypto7 = __toESM(require("crypto"));
85429
- import_promises18 = require("fs/promises");
85483
+ import_promises17 = require("fs/promises");
85430
85484
  import_node_path37 = require("path");
85431
85485
  import_esbuild3 = require("esbuild");
85432
85486
  init_bundle();
@@ -85506,8 +85560,8 @@ function buildPluginFromFunctions({
85506
85560
  args.resolveDir,
85507
85561
  args.path.slice("assets:".length)
85508
85562
  );
85509
- const exists = await (0, import_promises19.access)(directory).then(() => true).catch(() => false);
85510
- const isDirectory2 = exists && (await (0, import_promises19.lstat)(directory)).isDirectory();
85563
+ const exists = await (0, import_promises18.access)(directory).then(() => true).catch(() => false);
85564
+ const isDirectory2 = exists && (await (0, import_promises18.lstat)(directory)).isDirectory();
85511
85565
  if (!isDirectory2) {
85512
85566
  return {
85513
85567
  errors: [
@@ -85552,11 +85606,11 @@ function buildPluginFromFunctions({
85552
85606
  metafile: void 0
85553
85607
  });
85554
85608
  }
85555
- var import_promises19, import_node_path38;
85609
+ var import_promises18, import_node_path38;
85556
85610
  var init_buildPlugin = __esm({
85557
85611
  "src/pages/functions/buildPlugin.ts"() {
85558
85612
  init_import_meta_url();
85559
- import_promises19 = require("fs/promises");
85613
+ import_promises18 = require("fs/promises");
85560
85614
  import_node_path38 = require("path");
85561
85615
  init_bundle();
85562
85616
  init_module_collection();
@@ -85695,7 +85749,7 @@ async function forEachFile(baseDir, fn2) {
85695
85749
  const returnValues = [];
85696
85750
  while (isNotEmpty(searchPaths)) {
85697
85751
  const cwd2 = searchPaths.shift();
85698
- const dir = await import_promises20.default.readdir(cwd2, { withFileTypes: true });
85752
+ const dir = await import_promises19.default.readdir(cwd2, { withFileTypes: true });
85699
85753
  for (const entry of dir) {
85700
85754
  const pathname = import_node_path39.default.join(cwd2, entry.name);
85701
85755
  if (entry.isDirectory()) {
@@ -85732,11 +85786,11 @@ function convertSimpleParams(routePath) {
85732
85786
  }
85733
85787
  });
85734
85788
  }
85735
- var import_promises20, import_node_path39, import_esbuild4, validParamNameRegExp;
85789
+ var import_promises19, import_node_path39, import_esbuild4, validParamNameRegExp;
85736
85790
  var init_filepath_routing = __esm({
85737
85791
  "src/pages/functions/filepath-routing.ts"() {
85738
85792
  init_import_meta_url();
85739
- import_promises20 = __toESM(require("fs/promises"));
85793
+ import_promises19 = __toESM(require("fs/promises"));
85740
85794
  import_node_path39 = __toESM(require("path"));
85741
85795
  import_esbuild4 = require("esbuild");
85742
85796
  init_errors();
@@ -85832,7 +85886,7 @@ async function writeRoutesModule({
85832
85886
  }) {
85833
85887
  const { importMap, routes } = parseConfig(config, srcDir);
85834
85888
  const routesModule = generateRoutesModule(importMap, routes);
85835
- await import_promises21.default.writeFile(outfile, routesModule);
85889
+ await import_promises20.default.writeFile(outfile, routesModule);
85836
85890
  return outfile;
85837
85891
  }
85838
85892
  function parseConfig(config, baseDir) {
@@ -85897,11 +85951,11 @@ export const routes = [
85897
85951
  ).join("\n")}
85898
85952
  ]`;
85899
85953
  }
85900
- var import_promises21, import_node_path40;
85954
+ var import_promises20, import_node_path40;
85901
85955
  var init_routes2 = __esm({
85902
85956
  "src/pages/functions/routes.ts"() {
85903
85957
  init_import_meta_url();
85904
- import_promises21 = __toESM(require("fs/promises"));
85958
+ import_promises20 = __toESM(require("fs/promises"));
85905
85959
  import_node_path40 = __toESM(require("path"));
85906
85960
  init_errors();
85907
85961
  init_identifiers();
@@ -86169,7 +86223,7 @@ async function maybeReadPagesConfig(args) {
86169
86223
  });
86170
86224
  return {
86171
86225
  ...config,
86172
- hash: (0, import_node_crypto8.createHash)("sha256").update(await (0, import_promises22.readFile)(configPath)).digest("hex")
86226
+ hash: (0, import_node_crypto8.createHash)("sha256").update(await (0, import_promises21.readFile)(configPath)).digest("hex")
86173
86227
  };
86174
86228
  } catch (e7) {
86175
86229
  if (e7 instanceof FatalError && e7.code === EXIT_CODE_INVALID_PAGES_CONFIG) {
@@ -86178,13 +86232,13 @@ async function maybeReadPagesConfig(args) {
86178
86232
  throw e7;
86179
86233
  }
86180
86234
  }
86181
- var import_node_crypto8, import_node_fs22, import_promises22, import_node_path43, pagesFunctionsBuildCommand, validateArgs;
86235
+ var import_node_crypto8, import_node_fs22, import_promises21, import_node_path43, pagesFunctionsBuildCommand, validateArgs;
86182
86236
  var init_build4 = __esm({
86183
86237
  "src/pages/build.ts"() {
86184
86238
  init_import_meta_url();
86185
86239
  import_node_crypto8 = require("crypto");
86186
86240
  import_node_fs22 = require("fs");
86187
- import_promises22 = require("fs/promises");
86241
+ import_promises21 = require("fs/promises");
86188
86242
  import_node_path43 = __toESM(require("path"));
86189
86243
  init_create_worker_bundle_contents();
86190
86244
  init_config2();
@@ -86836,7 +86890,7 @@ async function deploy2({
86836
86890
  );
86837
86891
  }
86838
86892
  if (config !== void 0 && config.configPath !== void 0 && config.pages_build_output_dir) {
86839
- const configHash = (0, import_node_crypto9.createHash)("sha256").update(await (0, import_promises23.readFile)(config.configPath)).digest("hex");
86893
+ const configHash = (0, import_node_crypto9.createHash)("sha256").update(await (0, import_promises22.readFile)(config.configPath)).digest("hex");
86840
86894
  const outputDir = import_node_path45.default.relative(
86841
86895
  process.cwd(),
86842
86896
  config.pages_build_output_dir
@@ -86976,13 +87030,13 @@ async function deploy2({
86976
87030
  }
86977
87031
  throw lastErr;
86978
87032
  }
86979
- var import_node_crypto9, import_node_fs24, import_promises23, import_node_path45, import_node_process11, import_undici14;
87033
+ var import_node_crypto9, import_node_fs24, import_promises22, import_node_path45, import_node_process11, import_undici14;
86980
87034
  var init_deploy4 = __esm({
86981
87035
  "src/api/pages/deploy.ts"() {
86982
87036
  init_import_meta_url();
86983
87037
  import_node_crypto9 = require("crypto");
86984
87038
  import_node_fs24 = require("fs");
86985
- import_promises23 = require("fs/promises");
87039
+ import_promises22 = require("fs/promises");
86986
87040
  import_node_path45 = __toESM(require("path"));
86987
87041
  import_node_process11 = require("process");
86988
87042
  import_undici14 = __toESM(require_undici());
@@ -87401,12 +87455,12 @@ function promptSelectExistingOrNewProject(message, items) {
87401
87455
  choices: items.map((i5) => ({ title: i5.label, value: i5.value }))
87402
87456
  });
87403
87457
  }
87404
- var import_node_child_process5, import_promises24, import_node_path46, pagesDeploymentCreateCommand, pagesPublishCommand, pagesDeployCommand;
87458
+ var import_node_child_process5, import_promises23, import_node_path46, pagesDeploymentCreateCommand, pagesPublishCommand, pagesDeployCommand;
87405
87459
  var init_deploy5 = __esm({
87406
87460
  "src/pages/deploy.ts"() {
87407
87461
  init_import_meta_url();
87408
87462
  import_node_child_process5 = require("child_process");
87409
- import_promises24 = require("fs/promises");
87463
+ import_promises23 = require("fs/promises");
87410
87464
  import_node_path46 = __toESM(require("path"));
87411
87465
  init_deploy4();
87412
87466
  init_cfetch();
@@ -87750,7 +87804,7 @@ To silence this warning, pass in --commit-dirty=true`
87750
87804
  if (failureMessage.includes("Script startup exceeded CPU time limit")) {
87751
87805
  const workerBundle = formData.get("_worker.bundle");
87752
87806
  const filePath = import_node_path46.default.join(getPagesTmpDir(), "_worker.bundle");
87753
- await (0, import_promises24.writeFile)(filePath, workerBundle.stream());
87807
+ await (0, import_promises23.writeFile)(filePath, workerBundle.stream());
87754
87808
  await handleStartupError(filePath, getPagesProjectRoot());
87755
87809
  }
87756
87810
  throw new FatalError(
@@ -89315,11 +89369,11 @@ var init_createTail = __esm({
89315
89369
  });
89316
89370
 
89317
89371
  // src/pages/deployment-tails.ts
89318
- var import_promises25, import_signal_exit5, statusChoices, isStatusChoiceList, pagesDeploymentTailCommand;
89372
+ var import_promises24, import_signal_exit5, statusChoices, isStatusChoiceList, pagesDeploymentTailCommand;
89319
89373
  var init_deployment_tails = __esm({
89320
89374
  "src/pages/deployment-tails.ts"() {
89321
89375
  init_import_meta_url();
89322
- import_promises25 = require("timers/promises");
89376
+ import_promises24 = require("timers/promises");
89323
89377
  import_signal_exit5 = __toESM(require_signal_exit());
89324
89378
  init_cfetch();
89325
89379
  init_config2();
@@ -89541,10 +89595,10 @@ var init_deployment_tails = __esm({
89541
89595
  while (tail.readyState !== tail.OPEN) {
89542
89596
  switch (tail.readyState) {
89543
89597
  case tail.CONNECTING:
89544
- await (0, import_promises25.setTimeout)(100);
89598
+ await (0, import_promises24.setTimeout)(100);
89545
89599
  break;
89546
89600
  case tail.CLOSING:
89547
- await (0, import_promises25.setTimeout)(100);
89601
+ await (0, import_promises24.setTimeout)(100);
89548
89602
  break;
89549
89603
  case tail.CLOSED:
89550
89604
  sendMetricsEvent("end log stream", {
@@ -90722,7 +90776,7 @@ async function toEnvironment(deploymentConfig, accountId) {
90722
90776
  async function writeWranglerToml(toml) {
90723
90777
  let tomlString = import_toml5.default.stringify(toml);
90724
90778
  tomlString = tomlString.split("\n").map((line) => line.trimStart()).join("\n");
90725
- await (0, import_promises26.writeFile)(
90779
+ await (0, import_promises25.writeFile)(
90726
90780
  "wrangler.toml",
90727
90781
  `# Generated by Wrangler on ${/* @__PURE__ */ new Date()}
90728
90782
  ${tomlString}`
@@ -90779,12 +90833,12 @@ async function downloadProject(accountId, projectName) {
90779
90833
  }
90780
90834
  };
90781
90835
  }
90782
- var import_fs15, import_promises26, import_toml5, import_miniflare16, pagesDownloadConfigCommand;
90836
+ var import_fs15, import_promises25, import_toml5, import_miniflare16, pagesDownloadConfigCommand;
90783
90837
  var init_download_config = __esm({
90784
90838
  "src/pages/download-config.ts"() {
90785
90839
  init_import_meta_url();
90786
90840
  import_fs15 = require("fs");
90787
- import_promises26 = require("fs/promises");
90841
+ import_promises25 = require("fs/promises");
90788
90842
  import_toml5 = __toESM(require_toml());
90789
90843
  init_source();
90790
90844
  import_miniflare16 = require("miniflare");
@@ -113962,14 +114016,14 @@ var init_retry_wrapper = __esm({
113962
114016
  });
113963
114017
 
113964
114018
  // ../../node_modules/.pnpm/@aws-sdk+credential-provider-http@3.716.0/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js
113965
- var import_promises27, AWS_CONTAINER_CREDENTIALS_RELATIVE_URI, DEFAULT_LINK_LOCAL_HOST, AWS_CONTAINER_CREDENTIALS_FULL_URI, AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE, AWS_CONTAINER_AUTHORIZATION_TOKEN, fromHttp;
114019
+ var import_promises26, AWS_CONTAINER_CREDENTIALS_RELATIVE_URI, DEFAULT_LINK_LOCAL_HOST, AWS_CONTAINER_CREDENTIALS_FULL_URI, AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE, AWS_CONTAINER_AUTHORIZATION_TOKEN, fromHttp;
113966
114020
  var init_fromHttp = __esm({
113967
114021
  "../../node_modules/.pnpm/@aws-sdk+credential-provider-http@3.716.0/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js"() {
113968
114022
  init_import_meta_url();
113969
114023
  init_client5();
113970
114024
  init_dist_es12();
113971
114025
  init_dist_es17();
113972
- import_promises27 = __toESM(require("fs/promises"));
114026
+ import_promises26 = __toESM(require("fs/promises"));
113973
114027
  init_checkUrl();
113974
114028
  init_requestHelpers();
113975
114029
  init_retry_wrapper();
@@ -114013,7 +114067,7 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
114013
114067
  if (token) {
114014
114068
  request4.headers.Authorization = token;
114015
114069
  } else if (tokenFile) {
114016
- request4.headers.Authorization = (await import_promises27.default.readFile(tokenFile)).toString();
114070
+ request4.headers.Authorization = (await import_promises26.default.readFile(tokenFile)).toString();
114017
114071
  }
114018
114072
  try {
114019
114073
  const result = await requestHandler.handle(request4);
@@ -124521,7 +124575,7 @@ var init_dist_es73 = __esm({
124521
124575
  async function generateR2ServiceToken(accountId, bucketName, pipelineName) {
124522
124576
  const controller = new AbortController();
124523
124577
  const signal = controller.signal;
124524
- const timeoutPromise = (0, import_promises28.setTimeout)(12e4, "timeout", { signal });
124578
+ const timeoutPromise = (0, import_promises27.setTimeout)(12e4, "timeout", { signal });
124525
124579
  const serverPromise = new Promise((resolve24, reject) => {
124526
124580
  const server = import_node_http2.default.createServer(async (request4, response) => {
124527
124581
  (0, import_node_assert19.default)(request4.url, "This request doesn't have a URL");
@@ -124626,14 +124680,14 @@ async function deletePipeline(complianceConfig, accountId, name2) {
124626
124680
  }
124627
124681
  );
124628
124682
  }
124629
- var import_node_assert19, import_node_crypto10, import_node_http2, import_promises28, API_HEADERS;
124683
+ var import_node_assert19, import_node_crypto10, import_node_http2, import_promises27, API_HEADERS;
124630
124684
  var init_client7 = __esm({
124631
124685
  "src/pipelines/client.ts"() {
124632
124686
  init_import_meta_url();
124633
124687
  import_node_assert19 = __toESM(require("assert"));
124634
124688
  import_node_crypto10 = require("crypto");
124635
124689
  import_node_http2 = __toESM(require("http"));
124636
- import_promises28 = require("timers/promises");
124690
+ import_promises27 = require("timers/promises");
124637
124691
  init_cfetch();
124638
124692
  init_misc_variables();
124639
124693
  init_errors();
@@ -124670,7 +124724,7 @@ async function verifyBucketAccess(r22, bucketName) {
124670
124724
  if (attempt === MAX_ATTEMPTS2) {
124671
124725
  throw error2;
124672
124726
  }
124673
- await (0, import_promises29.setTimeout)(DELAY_MS);
124727
+ await (0, import_promises28.setTimeout)(DELAY_MS);
124674
124728
  }
124675
124729
  }
124676
124730
  }
@@ -124794,11 +124848,11 @@ function formatPipelinePretty(pipeline) {
124794
124848
  }
124795
124849
  return buffer;
124796
124850
  }
124797
- var import_promises29, BYTES_PER_MB, __testSkipDelaysFlag, pipelinesNamespace;
124851
+ var import_promises28, BYTES_PER_MB, __testSkipDelaysFlag, pipelinesNamespace;
124798
124852
  var init_pipelines = __esm({
124799
124853
  "src/pipelines/index.ts"() {
124800
124854
  init_import_meta_url();
124801
- import_promises29 = require("timers/promises");
124855
+ import_promises28 = require("timers/promises");
124802
124856
  init_dist_es73();
124803
124857
  init_pretty_bytes();
124804
124858
  init_create_command();
@@ -141393,11 +141447,11 @@ var init_sentry = __esm({
141393
141447
  });
141394
141448
 
141395
141449
  // src/tail/index.ts
141396
- var import_promises30, import_signal_exit6, tailCommand;
141450
+ var import_promises29, import_signal_exit6, tailCommand;
141397
141451
  var init_tail = __esm({
141398
141452
  "src/tail/index.ts"() {
141399
141453
  init_import_meta_url();
141400
- import_promises30 = require("timers/promises");
141454
+ import_promises29 = require("timers/promises");
141401
141455
  import_signal_exit6 = __toESM(require_signal_exit());
141402
141456
  init_config2();
141403
141457
  init_create_command();
@@ -141543,10 +141597,10 @@ var init_tail = __esm({
141543
141597
  while (tail.readyState !== tail.OPEN) {
141544
141598
  switch (tail.readyState) {
141545
141599
  case tail.CONNECTING:
141546
- await (0, import_promises30.setTimeout)(100);
141600
+ await (0, import_promises29.setTimeout)(100);
141547
141601
  break;
141548
141602
  case tail.CLOSING:
141549
- await (0, import_promises30.setTimeout)(100);
141603
+ await (0, import_promises29.setTimeout)(100);
141550
141604
  break;
141551
141605
  case tail.CLOSED:
141552
141606
  sendMetricsEvent("end log stream", {
@@ -141748,7 +141802,7 @@ async function generateRuntimeTypes({
141748
141802
  }
141749
141803
  const header = `// Runtime types generated with workerd@${import_workerd.version} ${compatibility_date} ${compatibility_flags.sort().join(",")}`;
141750
141804
  try {
141751
- const lines = (await (0, import_promises31.readFile)(outFile, "utf8")).split("\n");
141805
+ const lines = (await (0, import_promises30.readFile)(outFile, "utf8")).split("\n");
141752
141806
  const existingHeader = lines.find(
141753
141807
  (line) => line.startsWith("// Runtime types generated with workerd@")
141754
141808
  );
@@ -141800,12 +141854,12 @@ async function generate({
141800
141854
  await mf.dispose();
141801
141855
  }
141802
141856
  }
141803
- var import_fs24, import_promises31, import_miniflare19, import_workerd, DEFAULT_OUTFILE_RELATIVE_PATH;
141857
+ var import_fs24, import_promises30, import_miniflare19, import_workerd, DEFAULT_OUTFILE_RELATIVE_PATH;
141804
141858
  var init_runtime = __esm({
141805
141859
  "src/type-generation/runtime/index.ts"() {
141806
141860
  init_import_meta_url();
141807
141861
  import_fs24 = require("fs");
141808
- import_promises31 = require("fs/promises");
141862
+ import_promises30 = require("fs/promises");
141809
141863
  import_miniflare19 = require("miniflare");
141810
141864
  import_workerd = require("workerd");
141811
141865
  init_logger();
@@ -143088,8 +143142,8 @@ var init_client10 = __esm({
143088
143142
  // src/vectorize/common.ts
143089
143143
  async function isValidFile(path71) {
143090
143144
  try {
143091
- await (0, import_promises32.access)(path71, import_promises32.constants.R_OK);
143092
- const fileStat = await (0, import_promises32.stat)(path71);
143145
+ await (0, import_promises31.access)(path71, import_promises31.constants.R_OK);
143146
+ const fileStat = await (0, import_promises31.stat)(path71);
143093
143147
  return fileStat.isFile() && fileStat.size > 0;
143094
143148
  } catch (err) {
143095
143149
  return false;
@@ -143114,11 +143168,11 @@ async function* getBatchFromFile(rl, batchSize = VECTORIZE_MAX_BATCH_SIZE) {
143114
143168
  return;
143115
143169
  }
143116
143170
  }
143117
- var import_promises32, deprecatedV1DefaultFlag, VECTORIZE_V1_MAX_BATCH_SIZE, VECTORIZE_MAX_BATCH_SIZE, VECTORIZE_UPSERT_BATCH_SIZE, VECTORIZE_MAX_UPSERT_VECTOR_RECORDS;
143171
+ var import_promises31, deprecatedV1DefaultFlag, VECTORIZE_V1_MAX_BATCH_SIZE, VECTORIZE_MAX_BATCH_SIZE, VECTORIZE_UPSERT_BATCH_SIZE, VECTORIZE_MAX_UPSERT_VECTOR_RECORDS;
143118
143172
  var init_common3 = __esm({
143119
143173
  "src/vectorize/common.ts"() {
143120
143174
  init_import_meta_url();
143121
- import_promises32 = require("fs/promises");
143175
+ import_promises31 = require("fs/promises");
143122
143176
  init_logger();
143123
143177
  deprecatedV1DefaultFlag = false;
143124
143178
  VECTORIZE_V1_MAX_BATCH_SIZE = 1e3;
@@ -151609,7 +151663,7 @@ ${tryRunningItIn}${oneOfThese}`
151609
151663
  const controller = new AbortController();
151610
151664
  await Promise.race([
151611
151665
  Promise.allSettled(dispatcher?.requests ?? []),
151612
- (0, import_promises33.setTimeout)(1e3, void 0, controller)
151666
+ (0, import_promises32.setTimeout)(1e3, void 0, controller)
151613
151667
  // Ensure we don't hang indefinitely
151614
151668
  ]).then(() => controller.abort());
151615
151669
  } catch (e7) {
@@ -151620,12 +151674,12 @@ ${tryRunningItIn}${oneOfThese}`
151620
151674
  }
151621
151675
  }
151622
151676
  }
151623
- var import_node_os7, import_promises33, import_undici21;
151677
+ var import_node_os7, import_promises32, import_undici21;
151624
151678
  var init_src = __esm({
151625
151679
  "src/index.ts"() {
151626
151680
  init_import_meta_url();
151627
151681
  import_node_os7 = __toESM(require("os"));
151628
- import_promises33 = require("timers/promises");
151682
+ import_promises32 = require("timers/promises");
151629
151683
  init_source();
151630
151684
  import_undici21 = __toESM(require_undici());
151631
151685
  init_yargs();
@@ -151650,7 +151704,7 @@ var init_src = __esm({
151650
151704
  init_export();
151651
151705
  init_info();
151652
151706
  init_insights();
151653
- init_list();
151707
+ init_list2();
151654
151708
  init_migrations();
151655
151709
  init_apply2();
151656
151710
  init_create3();
@@ -151836,7 +151890,7 @@ async function checkStartupHandler({
151836
151890
  startMessage: "Analysing",
151837
151891
  endMessage: source_default.green("Startup phase analysed")
151838
151892
  });
151839
- await (0, import_promises35.writeFile)(outfile, JSON.stringify(await cpuProfileResult));
151893
+ await (0, import_promises34.writeFile)(outfile, JSON.stringify(await cpuProfileResult));
151840
151894
  log(
151841
151895
  `CPU Profile written to ${outfile}. Load it into the Chrome DevTools profiler (or directly in VSCode) to view a flamegraph.`
151842
151896
  );
@@ -151871,7 +151925,7 @@ async function convertWorkerBundleToModules(workerBundle) {
151871
151925
  );
151872
151926
  }
151873
151927
  async function parseFormDataFromFile(file) {
151874
- const bundle = await (0, import_promises34.readFile)(file);
151928
+ const bundle = await (0, import_promises33.readFile)(file);
151875
151929
  const firstLine = bundle.findIndex((v7) => v7 === 10);
151876
151930
  const boundary = Uint8Array.prototype.slice.call(bundle, 2, firstLine).toString();
151877
151931
  return await new Response(bundle, {
@@ -151937,14 +151991,14 @@ async function analyseBundle(workerBundle) {
151937
151991
  ws.send(JSON.stringify({ id: 3, method: "Profiler.stop", params: {} }));
151938
151992
  return cpuProfileResult;
151939
151993
  }
151940
- var import_crypto6, import_promises34, import_node_events3, import_promises35, import_path24, import_miniflare21, mimeTypeModuleType, checkNamespace, checkStartupCommand;
151994
+ var import_crypto6, import_promises33, import_node_events3, import_promises34, import_path24, import_miniflare21, mimeTypeModuleType, checkNamespace, checkStartupCommand;
151941
151995
  var init_commands9 = __esm({
151942
151996
  "src/check/commands.ts"() {
151943
151997
  init_import_meta_url();
151944
151998
  import_crypto6 = require("crypto");
151945
- import_promises34 = require("fs/promises");
151999
+ import_promises33 = require("fs/promises");
151946
152000
  import_node_events3 = __toESM(require("events"));
151947
- import_promises35 = require("fs/promises");
152001
+ import_promises34 = require("fs/promises");
151948
152002
  import_path24 = __toESM(require("path"));
151949
152003
  init_cli();
151950
152004
  init_interactive();
@@ -152042,7 +152096,7 @@ async function handleStartupError(workerBundle, projectRoot) {
152042
152096
  projectRoot ?? process.cwd(),
152043
152097
  import_node_path54.default.join(tmpDir.path, `worker.cpuprofile`)
152044
152098
  );
152045
- await (0, import_promises36.writeFile)(profile, JSON.stringify(cpuProfile));
152099
+ await (0, import_promises35.writeFile)(profile, JSON.stringify(cpuProfile));
152046
152100
  throw new UserError(esm_default2`
152047
152101
  Your Worker failed validation because it exceeded startup limits.
152048
152102
  To ensure fast responses, there are constraints on Worker startup, such as how much CPU it can use, or how long it can take. Your Worker has hit one of these startup limits. Try reducing the amount of work done during startup (outside the event handler), either by removing code or relocating it inside the event handler.
@@ -152058,11 +152112,11 @@ async function helpIfErrorIsSizeOrScriptStartup(err, dependencies, workerBundle,
152058
152112
  await handleStartupError(workerBundle, projectRoot);
152059
152113
  }
152060
152114
  }
152061
- var import_promises36, import_node_path54, scriptStartupErrorRegex;
152115
+ var import_promises35, import_node_path54, scriptStartupErrorRegex;
152062
152116
  var init_friendly_validator_errors = __esm({
152063
152117
  "src/utils/friendly-validator-errors.ts"() {
152064
152118
  init_import_meta_url();
152065
- import_promises36 = require("fs/promises");
152119
+ import_promises35 = require("fs/promises");
152066
152120
  import_node_path54 = __toESM(require("path"));
152067
152121
  init_esm2();
152068
152122
  init_commands9();
@@ -153870,7 +153924,11 @@ If you are trying to develop Pages and Workers together, please use \`wrangler p
153870
153924
  (c6) => !isDockerfile(c6.image ?? c6.configuration.image)
153871
153925
  );
153872
153926
  if (needsPulling && !resolved.dev.remote) {
153873
- await fillOpenAPIConfiguration(config, isNonInteractiveOrCI());
153927
+ await fillOpenAPIConfiguration(
153928
+ config,
153929
+ isNonInteractiveOrCI(),
153930
+ containersScope
153931
+ );
153874
153932
  }
153875
153933
  const queues = extractBindingsOfType("queue", resolved.bindings);
153876
153934
  if (resolved.dev.remote && (queues?.length || resolved.triggers?.some((t7) => t7.type === "queue-consumer"))) {
@@ -153901,6 +153959,7 @@ var init_ConfigController = __esm({
153901
153959
  init_assets();
153902
153960
  init_common();
153903
153961
  init_config2();
153962
+ init_containers2();
153904
153963
  init_entry();
153905
153964
  init_dev2();
153906
153965
  init_class_names_sqlite();
@@ -174121,7 +174180,7 @@ async function getBinaryFileContents2(file) {
174121
174180
  }
174122
174181
  return Buffer.from(file.contents);
174123
174182
  }
174124
- return (0, import_promises37.readFile)(file.path);
174183
+ return (0, import_promises36.readFile)(file.path);
174125
174184
  }
174126
174185
  async function getTextFileContents(file) {
174127
174186
  if ("contents" in file) {
@@ -174133,7 +174192,7 @@ async function getTextFileContents(file) {
174133
174192
  }
174134
174193
  return Buffer.from(file.contents).toString();
174135
174194
  }
174136
- return (0, import_promises37.readFile)(file.path, "utf8");
174195
+ return (0, import_promises36.readFile)(file.path, "utf8");
174137
174196
  }
174138
174197
  function getName2(config) {
174139
174198
  return config.name;
@@ -174243,13 +174302,13 @@ async function getContainerOptions(config) {
174243
174302
  }
174244
174303
  return containers2;
174245
174304
  }
174246
- var import_node_assert29, import_node_crypto14, import_promises37, import_miniflare26, LocalRuntimeController;
174305
+ var import_node_assert29, import_node_crypto14, import_promises36, import_miniflare26, LocalRuntimeController;
174247
174306
  var init_LocalRuntimeController = __esm({
174248
174307
  "src/api/startDevWorker/LocalRuntimeController.ts"() {
174249
174308
  init_import_meta_url();
174250
174309
  import_node_assert29 = __toESM(require("assert"));
174251
174310
  import_node_crypto14 = require("crypto");
174252
- import_promises37 = require("fs/promises");
174311
+ import_promises36 = require("fs/promises");
174253
174312
  init_containers_shared();
174254
174313
  init_source();
174255
174314
  import_miniflare26 = require("miniflare");
@@ -174739,8 +174798,8 @@ async function registerWorker(name2, definition) {
174739
174798
  if (existingHeartbeat) {
174740
174799
  clearInterval(existingHeartbeat);
174741
174800
  }
174742
- await (0, import_promises38.mkdir)(DEV_REGISTRY_PATH, { recursive: true });
174743
- await (0, import_promises38.writeFile)(
174801
+ await (0, import_promises37.mkdir)(DEV_REGISTRY_PATH, { recursive: true });
174802
+ await (0, import_promises37.writeFile)(
174744
174803
  import_node_path64.default.join(DEV_REGISTRY_PATH, name2),
174745
174804
  // We don't currently do anything with the stored Wrangler version,
174746
174805
  // but if we need to make breaking changes to this format in the future
@@ -174761,7 +174820,7 @@ async function getRegisteredWorkers() {
174761
174820
  }
174762
174821
  async function unregisterWorker(name2) {
174763
174822
  try {
174764
- await (0, import_promises38.unlink)(import_node_path64.default.join(DEV_REGISTRY_PATH, name2));
174823
+ await (0, import_promises37.unlink)(import_node_path64.default.join(DEV_REGISTRY_PATH, name2));
174765
174824
  const existingHeartbeat = heartbeats.get(name2);
174766
174825
  if (existingHeartbeat) {
174767
174826
  clearInterval(existingHeartbeat);
@@ -174772,17 +174831,17 @@ async function unregisterWorker(name2) {
174772
174831
  return;
174773
174832
  }
174774
174833
  async function loadWorkerDefinitions() {
174775
- await (0, import_promises38.mkdir)(DEV_REGISTRY_PATH, { recursive: true });
174834
+ await (0, import_promises37.mkdir)(DEV_REGISTRY_PATH, { recursive: true });
174776
174835
  globalWorkers ??= {};
174777
174836
  const newWorkers = /* @__PURE__ */ new Set();
174778
- const workerDefinitions = await (0, import_promises38.readdir)(DEV_REGISTRY_PATH);
174837
+ const workerDefinitions = await (0, import_promises37.readdir)(DEV_REGISTRY_PATH);
174779
174838
  for (const workerName of workerDefinitions) {
174780
174839
  try {
174781
- const file = await (0, import_promises38.readFile)(
174840
+ const file = await (0, import_promises37.readFile)(
174782
174841
  import_node_path64.default.join(DEV_REGISTRY_PATH, workerName),
174783
174842
  "utf8"
174784
174843
  );
174785
- const stats = await (0, import_promises38.stat)(import_node_path64.default.join(DEV_REGISTRY_PATH, workerName));
174844
+ const stats = await (0, import_promises37.stat)(import_node_path64.default.join(DEV_REGISTRY_PATH, workerName));
174786
174845
  if (stats.mtime.getTime() < Date.now() - 6e5) {
174787
174846
  await unregisterWorker(workerName);
174788
174847
  } else {
@@ -174803,12 +174862,12 @@ async function loadWorkerDefinitions() {
174803
174862
  }
174804
174863
  return globalWorkers;
174805
174864
  }
174806
- var import_node_fs34, import_promises38, import_node_path64, util3, DEV_REGISTRY_PATH, heartbeats, globalWorkers, globalWatcher, FileRegistry;
174865
+ var import_node_fs34, import_promises37, import_node_path64, util3, DEV_REGISTRY_PATH, heartbeats, globalWorkers, globalWatcher, FileRegistry;
174807
174866
  var init_file_registry = __esm({
174808
174867
  "src/dev-registry/file-registry.ts"() {
174809
174868
  init_import_meta_url();
174810
174869
  import_node_fs34 = require("fs");
174811
- import_promises38 = require("fs/promises");
174870
+ import_promises37 = require("fs/promises");
174812
174871
  import_node_path64 = __toESM(require("path"));
174813
174872
  util3 = __toESM(require("util"));
174814
174873
  init_esm4();
@@ -175010,6 +175069,24 @@ function registerDevHotKeys(devEnv, args) {
175010
175069
  );
175011
175070
  }, "handler")
175012
175071
  },
175072
+ {
175073
+ keys: ["r"],
175074
+ label: "rebuild container(s)",
175075
+ disabled: /* @__PURE__ */ __name(() => {
175076
+ return !devEnv.config.latestConfig?.dev?.enableContainers || !devEnv.config.latestConfig?.containers?.length;
175077
+ }, "disabled"),
175078
+ handler: /* @__PURE__ */ __name(async () => {
175079
+ const newContainerBuildId = (0, import_crypto7.randomUUID)().slice(0, 8);
175080
+ devEnv.runtimes.map(async (runtime) => {
175081
+ if (runtime instanceof LocalRuntimeController) {
175082
+ await runtime.cleanupContainers();
175083
+ }
175084
+ });
175085
+ await devEnv.config.patch({
175086
+ dev: { containerBuildId: newContainerBuildId }
175087
+ });
175088
+ }, "handler")
175089
+ },
175013
175090
  {
175014
175091
  keys: ["l"],
175015
175092
  disabled: /* @__PURE__ */ __name(() => args.forceLocal ?? false, "disabled"),
@@ -175035,25 +175112,6 @@ function registerDevHotKeys(devEnv, args) {
175035
175112
  handler: /* @__PURE__ */ __name(async () => {
175036
175113
  await devEnv.teardown();
175037
175114
  }, "handler")
175038
- },
175039
- {
175040
- keys: ["r"],
175041
- // omitting the label means it won't be printed but is still enabled
175042
- // label: "rebuild container",
175043
- handler: /* @__PURE__ */ __name(async () => {
175044
- if (!devEnv.config.latestConfig?.dev?.enableContainers || !devEnv.config.latestConfig?.containers?.length) {
175045
- return;
175046
- }
175047
- const newContainerBuildId = (0, import_crypto7.randomUUID)().slice(0, 8);
175048
- devEnv.runtimes.map(async (runtime) => {
175049
- if (runtime instanceof LocalRuntimeController) {
175050
- await runtime.cleanupContainers();
175051
- }
175052
- });
175053
- await devEnv.config.patch({
175054
- dev: { containerBuildId: newContainerBuildId }
175055
- });
175056
- }, "handler")
175057
175115
  }
175058
175116
  ]);
175059
175117
  return unregisterHotKeys;
@@ -177585,9 +177643,6 @@ async function startDev(args) {
177585
177643
  if (Array.isArray(args.config)) {
177586
177644
  const runtime = new MultiworkerRuntimeController(args.config.length);
177587
177645
  const primaryDevEnv = new DevEnv({ runtimes: [runtime] });
177588
- if (isInteractive2() && args.showInteractiveDevSession !== false) {
177589
- unregisterHotKeys = registerDevHotKeys(primaryDevEnv, args);
177590
- }
177591
177646
  devEnv = [
177592
177647
  await setupDevEnv(primaryDevEnv, args.config[0], authHook, {
177593
177648
  ...args,
@@ -177613,6 +177668,9 @@ async function startDev(args) {
177613
177668
  })
177614
177669
  )
177615
177670
  );
177671
+ if (isInteractive2() && args.showInteractiveDevSession !== false) {
177672
+ unregisterHotKeys = registerDevHotKeys(primaryDevEnv, args);
177673
+ }
177616
177674
  } else {
177617
177675
  devEnv = new DevEnv();
177618
177676
  void devEnv.proxy.ready.promise.then(({ url: url4 }) => {
@@ -177652,10 +177710,10 @@ async function startDev(args) {
177652
177710
  );
177653
177711
  });
177654
177712
  }
177713
+ await setupDevEnv(devEnv, args.config, authHook, args);
177655
177714
  if (isInteractive2() && args.showInteractiveDevSession !== false) {
177656
177715
  unregisterHotKeys = registerDevHotKeys(devEnv, args);
177657
177716
  }
177658
- await setupDevEnv(devEnv, args.config, authHook, args);
177659
177717
  }
177660
177718
  return {
177661
177719
  devEnv: Array.isArray(devEnv) ? devEnv[0] : devEnv,