@cloudflare/deploy-helpers 0.6.7 → 0.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -6758,11 +6758,15 @@ async function getMigrationsToUpload(scriptName, props) {
6758
6758
  suppressNotFoundError(err);
6759
6759
  }
6760
6760
  } else {
6761
- const scripts = await fetchResult(
6762
- config2,
6763
- `/accounts/${accountId}/workers/scripts`
6764
- );
6765
- script = scripts.find(({ id }) => id === scriptName);
6761
+ try {
6762
+ const serviceMetadata = await fetchResult(
6763
+ config2,
6764
+ `/accounts/${accountId}/workers/services/${scriptName}`
6765
+ );
6766
+ script = serviceMetadata.default_environment.script;
6767
+ } catch (err) {
6768
+ suppressNotFoundError(err);
6769
+ }
6766
6770
  }
6767
6771
  if (script?.migration_tag) {
6768
6772
  const scriptMigrationTag = script.migration_tag;
@@ -26556,7 +26560,7 @@ async function deletePreview(config2, accountId, workerName, previewIdentifier)
26556
26560
  );
26557
26561
  }
26558
26562
  __name(deletePreview, "deletePreview");
26559
- async function getPreviewDeployment(config2, accountId, workerName, previewIdentifier, deploymentIdentifier) {
26563
+ async function getPreviewDeployment(config2, accountId, workerName, previewIdentifier, deploymentIdentifier = "latest") {
26560
26564
  return fetchResult(
26561
26565
  config2,
26562
26566
  `/accounts/${accountId}/workers/workers/${workerName}/previews/${encodeURIComponent(
@@ -26581,6 +26585,20 @@ async function createPreviewDeployment(config2, accountId, workerName, previewId
26581
26585
  );
26582
26586
  }
26583
26587
  __name(createPreviewDeployment, "createPreviewDeployment");
26588
+ async function patchPreviewDeployment(config2, accountId, workerName, previewIdentifier, env, annotations, deploymentIdentifier = "latest") {
26589
+ return fetchResult(
26590
+ config2,
26591
+ `/accounts/${accountId}/workers/workers/${workerName}/previews/${encodeURIComponent(
26592
+ previewIdentifier
26593
+ )}/deployments/${encodeURIComponent(deploymentIdentifier)}`,
26594
+ {
26595
+ method: "PATCH",
26596
+ headers: { "Content-Type": "application/merge-patch+json" },
26597
+ body: JSON.stringify({ env, annotations })
26598
+ }
26599
+ );
26600
+ }
26601
+ __name(patchPreviewDeployment, "patchPreviewDeployment");
26584
26602
  async function getWorkerPreviewDefaults(config2, accountId, workerName) {
26585
26603
  const worker = await fetchResult(
26586
26604
  config2,
@@ -26602,6 +26620,27 @@ async function editWorkerPreviewDefaults(config2, accountId, workerName, preview
26602
26620
  return worker.preview_defaults ?? {};
26603
26621
  }
26604
26622
  __name(editWorkerPreviewDefaults, "editWorkerPreviewDefaults");
26623
+ async function getPreviewBaseConfig(config2, accountId, workerName) {
26624
+ const worker = await fetchResult(
26625
+ config2,
26626
+ `/accounts/${accountId}/workers/workers/${workerName}`
26627
+ );
26628
+ return worker.previews_base_config ?? {};
26629
+ }
26630
+ __name(getPreviewBaseConfig, "getPreviewBaseConfig");
26631
+ async function patchPreviewBaseConfig(config2, accountId, workerName, previewBaseConfig) {
26632
+ const worker = await fetchResult(
26633
+ config2,
26634
+ `/accounts/${accountId}/workers/workers/${workerName}`,
26635
+ {
26636
+ method: "PATCH",
26637
+ headers: { "Content-Type": "application/merge-patch+json" },
26638
+ body: JSON.stringify({ previews_base_config: previewBaseConfig })
26639
+ }
26640
+ );
26641
+ return worker.previews_base_config ?? {};
26642
+ }
26643
+ __name(patchPreviewBaseConfig, "patchPreviewBaseConfig");
26605
26644
  function getBranchName2() {
26606
26645
  const workersCIBranch = getWorkersCIBranchName();
26607
26646
  if (workersCIBranch) {
@@ -26915,192 +26954,6 @@ function assemblePreviewDefaults(config2) {
26915
26954
  return previewDefaults;
26916
26955
  }
26917
26956
  __name(assemblePreviewDefaults, "assemblePreviewDefaults");
26918
-
26919
- // src/preview/box.ts
26920
- var BOX = {
26921
- topLeft: "\u256D",
26922
- topRight: "\u256E",
26923
- bottomLeft: "\u2570",
26924
- bottomRight: "\u256F",
26925
- horizontal: "\u2500",
26926
- vertical: "\u2502",
26927
- bottomLeftWithConnector: "\u252C",
26928
- connectorRight: "\u2524"
26929
- };
26930
- function stripAnsi(str) {
26931
- return str.replace(/\x1b\[[0-9;]*m/g, "");
26932
- }
26933
- __name(stripAnsi, "stripAnsi");
26934
- function visibleLength(str) {
26935
- return stripAnsi(str).length;
26936
- }
26937
- __name(visibleLength, "visibleLength");
26938
- function padToVisibleWidth(str, width) {
26939
- const visible = visibleLength(str);
26940
- return str + " ".repeat(Math.max(0, width - visible));
26941
- }
26942
- __name(padToVisibleWidth, "padToVisibleWidth");
26943
- function drawBox(contentLines, options = {}) {
26944
- const lines = [...contentLines, ...options.footerLines ?? []];
26945
- const maxContentWidth = Math.max(
26946
- ...lines.map((line) => visibleLength(line)),
26947
- 0
26948
- );
26949
- const boxWidth = maxContentWidth + 4;
26950
- const horizontalLine = BOX.horizontal.repeat(boxWidth - 2);
26951
- const topBorder = `${BOX.topLeft}${horizontalLine}${BOX.topRight}`;
26952
- const bottomBorder = options.connectToChild ? `${BOX.bottomLeft}${BOX.horizontal}${BOX.bottomLeftWithConnector}${BOX.horizontal.repeat(boxWidth - 4)}${BOX.bottomRight}` : `${BOX.bottomLeft}${horizontalLine}${BOX.bottomRight}`;
26953
- const paddedLines = lines.map((line) => {
26954
- const paddedContent = padToVisibleWidth(line, maxContentWidth);
26955
- return `${BOX.vertical} ${paddedContent} ${BOX.vertical}`;
26956
- });
26957
- return [topBorder, ...paddedLines, bottomBorder].join("\n");
26958
- }
26959
- __name(drawBox, "drawBox");
26960
- function drawConnectedChildBox(contentLines, options = {}) {
26961
- const indent = options.indent ?? " ";
26962
- const lines = [...contentLines, ...options.footerLines ?? []];
26963
- const maxContentWidth = lines.length > 0 ? Math.max(...lines.map((line) => visibleLength(line))) : 0;
26964
- const boxWidth = maxContentWidth + 4;
26965
- const horizontalLine = BOX.horizontal.repeat(boxWidth - 2);
26966
- const topBorder = `${BOX.topLeft}${horizontalLine}${BOX.topRight}`;
26967
- const bottomBorder = `${BOX.bottomLeft}${horizontalLine}${BOX.bottomRight}`;
26968
- const paddedLines = lines.map((line) => {
26969
- const paddedContent = padToVisibleWidth(line, maxContentWidth);
26970
- return `${BOX.vertical} ${paddedContent} ${BOX.vertical}`;
26971
- });
26972
- const connectorIndex = options.connectorLineIndex ?? Math.floor(paddedLines.length / 2);
26973
- const result = [];
26974
- result.push(`${indent}${BOX.vertical}`);
26975
- result.push(`${indent}${BOX.vertical} ${topBorder}`);
26976
- paddedLines.forEach((line, index) => {
26977
- if (index === connectorIndex) {
26978
- result.push(
26979
- `${indent}${BOX.bottomLeft}${BOX.horizontal}${BOX.connectorRight}${line.slice(1)}`
26980
- );
26981
- } else if (index < connectorIndex) {
26982
- result.push(`${indent}${BOX.vertical} ${line}`);
26983
- } else {
26984
- result.push(`${indent} ${line}`);
26985
- }
26986
- });
26987
- result.push(`${indent} ${bottomBorder}`);
26988
- return result.join("\n");
26989
- }
26990
- __name(drawConnectedChildBox, "drawConnectedChildBox");
26991
- var CONFIG_MARKER = chalk6.hex("#FFA500")("\u25C6");
26992
- function getFriendlyBindingType(bindingType) {
26993
- return getBindingTypeFriendlyName(
26994
- bindingType
26995
- );
26996
- }
26997
- __name(getFriendlyBindingType, "getFriendlyBindingType");
26998
- function formatAlignedRows(rows, indent = " ") {
26999
- const labelWidth = Math.max(...rows.map(([label]) => label.length));
27000
- const valueWidth = Math.max(...rows.map(([, value]) => value.length));
27001
- return rows.map(([label, value, fromConfig]) => {
27002
- const marker = fromConfig ? CONFIG_MARKER : " ";
27003
- const coloredLabel = chalk6.cyan(padToVisibleWidth(label, labelWidth));
27004
- return `${indent}${coloredLabel} ${padToVisibleWidth(
27005
- value,
27006
- valueWidth
27007
- )} ${marker}`;
27008
- });
27009
- }
27010
- __name(formatAlignedRows, "formatAlignedRows");
27011
- function formatBindings(env, indent = " ", options = {}) {
27012
- const showSourceMarker = options.showSourceMarker ?? true;
27013
- const entries = Object.entries(env);
27014
- if (entries.length === 0) {
27015
- return [`${indent}${chalk6.dim("(none)")}`];
27016
- }
27017
- const nameWidth = Math.max(...entries.map(([name]) => name.length));
27018
- const typeWidth = Math.max(
27019
- ...entries.map(
27020
- ([, binding]) => visibleLength(getFriendlyBindingType(binding.type))
27021
- )
27022
- );
27023
- const valueWidth = Math.max(
27024
- ...entries.map(([, binding]) => getBindingValue(binding).length)
27025
- );
27026
- return entries.map(([name, binding]) => {
27027
- const value = getBindingValue(binding);
27028
- const friendlyType = getFriendlyBindingType(binding.type);
27029
- const coloredName = chalk6.cyan(padToVisibleWidth(name, nameWidth));
27030
- const dimType = chalk6.dim(padToVisibleWidth(friendlyType, typeWidth));
27031
- if (showSourceMarker) {
27032
- const marker = binding.fromConfig ? CONFIG_MARKER : " ";
27033
- return `${indent}${coloredName} ${dimType} ${padToVisibleWidth(
27034
- value,
27035
- valueWidth
27036
- )} ${marker}`;
27037
- }
27038
- return `${indent}${coloredName} ${dimType} ${padToVisibleWidth(
27039
- value,
27040
- valueWidth
27041
- )}`;
27042
- });
27043
- }
27044
- __name(formatBindings, "formatBindings");
27045
- function formatPreviewsSettings(workerName, previewDefaults) {
27046
- const lines = [];
27047
- lines.push(`${chalk6.bold.hex("#FFA500")("Worker:")} ${workerName}`);
27048
- lines.push("");
27049
- lines.push(` ${chalk6.bold.underline("Previews settings")}`);
27050
- lines.push("");
27051
- const settingsRows = [];
27052
- if (previewDefaults.observability && typeof previewDefaults.observability === "object") {
27053
- const enabledLabel = previewDefaults.observability.enabled ? "enabled" : "disabled";
27054
- const sampling = typeof previewDefaults.observability.head_sampling_rate === "number" ? `, ${previewDefaults.observability.head_sampling_rate.toFixed(
27055
- 1
27056
- )} sampling` : "";
27057
- settingsRows.push(["observability", `${enabledLabel}${sampling}`]);
27058
- }
27059
- if (typeof previewDefaults.logpush === "boolean") {
27060
- settingsRows.push([
27061
- "logpush",
27062
- previewDefaults.logpush ? "enabled" : "disabled"
27063
- ]);
27064
- }
27065
- if (typeof previewDefaults.limits?.cpu_ms === "number" || typeof previewDefaults.limits?.subrequests === "number") {
27066
- const limitParts = [
27067
- typeof previewDefaults.limits?.cpu_ms === "number" ? `cpu_ms: ${previewDefaults.limits.cpu_ms}` : void 0,
27068
- typeof previewDefaults.limits?.subrequests === "number" ? `subrequests: ${previewDefaults.limits.subrequests}` : void 0
27069
- ].filter((value) => value !== void 0);
27070
- settingsRows.push(["limits", limitParts.join(", ")]);
27071
- }
27072
- if (typeof previewDefaults.placement?.mode === "string") {
27073
- settingsRows.push(["placement", previewDefaults.placement.mode]);
27074
- }
27075
- if (previewDefaults.cache !== void 0) {
27076
- settingsRows.push([
27077
- "cache",
27078
- previewDefaults.cache.enabled ? "enabled" : "disabled"
27079
- ]);
27080
- }
27081
- if (settingsRows.length > 0) {
27082
- const labelWidth = Math.max(...settingsRows.map(([label]) => label.length));
27083
- for (const [label, value] of settingsRows) {
27084
- lines.push(
27085
- ` ${chalk6.cyan(padToVisibleWidth(label, labelWidth))} ${value}`
27086
- );
27087
- }
27088
- }
27089
- lines.push("");
27090
- lines.push(chalk6.bold(" Bindings"));
27091
- const env = Object.fromEntries(
27092
- Object.entries(previewDefaults.env ?? {}).map(([name, binding]) => [
27093
- name,
27094
- { ...binding, fromConfig: false }
27095
- ])
27096
- );
27097
- lines.push(...formatBindings(env));
27098
- lines.push("");
27099
- return drawBox(lines);
27100
- }
27101
- __name(formatPreviewsSettings, "formatPreviewsSettings");
27102
-
27103
- // src/preview/preview.ts
27104
26957
  function toBase64(content) {
27105
26958
  return Buffer.from(content).toString("base64");
27106
26959
  }
@@ -27266,221 +27119,31 @@ async function assemblePreviewDeploymentSettings(config2, buildResult, accountId
27266
27119
  return request2;
27267
27120
  }
27268
27121
  __name(assemblePreviewDeploymentSettings, "assemblePreviewDeploymentSettings");
27269
- function buildMergedScriptLevel(config2, previewResource) {
27270
- const previews = config2.previews;
27271
- const result = {};
27272
- const configHasObservability = previews?.observability !== void 0 || config2.observability !== void 0;
27273
- const configHasLogpush = previews?.logpush !== void 0 || config2.logpush !== void 0;
27274
- if (previewResource.observability !== void 0) {
27275
- result.observability = {
27276
- enabled: previewResource.observability.enabled,
27277
- head_sampling_rate: previewResource.observability.head_sampling_rate,
27278
- fromConfig: configHasObservability
27279
- };
27280
- }
27281
- if (previewResource.logpush !== void 0) {
27282
- result.logpush = {
27283
- value: previewResource.logpush,
27284
- fromConfig: configHasLogpush
27285
- };
27286
- }
27287
- if (previewResource.tail_consumers && previewResource.tail_consumers.length > 0) {
27288
- result.tail_consumers = previewResource.tail_consumers;
27289
- }
27290
- return result;
27291
- }
27292
- __name(buildMergedScriptLevel, "buildMergedScriptLevel");
27293
- function buildMergedVersionLevel(config2, deployment) {
27294
- const previews = config2.previews;
27295
- const configBindingNames = new Set(
27296
- Object.keys(extractConfigBindings(config2))
27297
- );
27298
- const result = { env: {} };
27299
- if (deployment.compatibility_date) {
27300
- result.compatibility_date = {
27301
- value: deployment.compatibility_date,
27302
- fromConfig: !!config2.compatibility_date
27303
- };
27304
- }
27305
- if (deployment.compatibility_flags && deployment.compatibility_flags.length > 0) {
27306
- result.compatibility_flags = {
27307
- value: deployment.compatibility_flags,
27308
- fromConfig: !!(config2.compatibility_flags && config2.compatibility_flags.length > 0)
27309
- };
27310
- }
27311
- if (deployment.limits?.cpu_ms !== void 0 || deployment.limits?.subrequests !== void 0) {
27312
- result.limits = {
27313
- value: {
27314
- ...deployment.limits?.cpu_ms !== void 0 && {
27315
- cpu_ms: deployment.limits.cpu_ms
27316
- },
27317
- ...deployment.limits?.subrequests !== void 0 && {
27318
- subrequests: deployment.limits.subrequests
27319
- }
27320
- },
27321
- fromConfig: !!(previews?.limits !== void 0 || config2.limits !== void 0)
27322
- };
27323
- }
27324
- if (deployment.placement?.mode) {
27325
- result.placement = {
27326
- value: { mode: deployment.placement.mode },
27327
- fromConfig: !!config2.placement?.mode
27328
- };
27329
- }
27330
- if (deployment.cache !== void 0) {
27331
- result.cache = {
27332
- value: deployment.cache,
27333
- fromConfig: previews?.cache !== void 0 || config2.cache !== void 0
27334
- };
27335
- }
27336
- if (config2.assets) {
27337
- result.assets = {
27338
- value: {
27339
- directory: config2.assets.directory,
27340
- binding: config2.assets.binding,
27341
- html_handling: config2.assets.html_handling,
27342
- not_found_handling: config2.assets.not_found_handling,
27343
- run_worker_first: config2.assets.run_worker_first
27344
- },
27345
- fromConfig: true
27346
- };
27122
+ function formatUrlLines(label, urls) {
27123
+ if (urls === void 0 || urls.length === 0) {
27124
+ return [];
27347
27125
  }
27348
- for (const [name, binding] of Object.entries(deployment.env ?? {})) {
27349
- result.env[name] = { ...binding, fromConfig: configBindingNames.has(name) };
27126
+ const firstUrl = urls[0];
27127
+ if (urls.length === 1 && firstUrl !== void 0) {
27128
+ return [`${chalk6.bold(`${label} URL:`)} ${chalk6.underline(firstUrl)}`];
27350
27129
  }
27351
- return result;
27130
+ return [
27131
+ chalk6.bold(`${label} URLs:`),
27132
+ ...urls.map((url3) => ` ${chalk6.underline(url3)}`)
27133
+ ];
27352
27134
  }
27353
- __name(buildMergedVersionLevel, "buildMergedVersionLevel");
27354
- function formatPreviewResource(previewResource, scriptLevel, isNew, configName) {
27135
+ __name(formatUrlLines, "formatUrlLines");
27136
+ function formatPreviewDeploymentSummary(previewResource, deployment, isNew) {
27355
27137
  const statusLabel = isNew ? chalk6.green("(new)") : chalk6.dim("(updated)");
27356
- const obsEnabled = scriptLevel.observability?.enabled ?? false;
27357
- const obsRate = scriptLevel.observability?.head_sampling_rate;
27358
- const formattedRate = obsRate !== void 0 ? obsRate.toFixed(1) : void 0;
27359
- const obsValue = obsEnabled ? `enabled${formattedRate !== void 0 ? `, ${formattedRate} sampling` : ""}` : "disabled";
27360
- const lines = [
27138
+ return [
27361
27139
  `${chalk6.bold("Preview:")} ${previewResource.name} ${statusLabel}`,
27140
+ ...formatUrlLines("Preview", previewResource.urls),
27362
27141
  "",
27363
- ...(previewResource.urls ?? []).map(
27364
- (url3) => ` ${chalk6.bold.underline(url3)}`
27365
- )
27366
- ];
27367
- const settingsRows = [];
27368
- if (scriptLevel.observability !== void 0) {
27369
- settingsRows.push([
27370
- "observability",
27371
- obsValue,
27372
- scriptLevel.observability.fromConfig
27373
- ]);
27374
- }
27375
- if (scriptLevel.logpush !== void 0) {
27376
- settingsRows.push([
27377
- "logpush",
27378
- scriptLevel.logpush.value ? "enabled" : "disabled",
27379
- scriptLevel.logpush.fromConfig
27380
- ]);
27381
- }
27382
- if (scriptLevel.tail_consumers && scriptLevel.tail_consumers.length > 0) {
27383
- settingsRows.push([
27384
- "tail_consumers",
27385
- scriptLevel.tail_consumers.map((tc) => tc.name).join(", "),
27386
- false
27387
- ]);
27388
- }
27389
- if (settingsRows.length > 0) {
27390
- lines.push("");
27391
- lines.push(...formatAlignedRows(settingsRows));
27392
- }
27393
- const hasConfigValues = settingsRows.some(([, , fromConfig]) => fromConfig);
27394
- const footerLines = hasConfigValues ? ["", chalk6.hex("#FFA500")(`\u25C6 from ${configName}`)] : void 0;
27395
- return drawBox(lines, { footerLines, connectToChild: true });
27396
- }
27397
- __name(formatPreviewResource, "formatPreviewResource");
27398
- function formatDeploymentResource(deployment, versionLevel, configName) {
27399
- const lines = [
27400
- `${chalk6.bold("Deployment:")} ${deployment.id}`,
27401
- "",
27402
- ...(deployment.urls ?? []).map((url3) => ` ${chalk6.bold.underline(url3)}`)
27403
- ];
27404
- const settingsRows = [];
27405
- if (versionLevel.compatibility_date) {
27406
- settingsRows.push([
27407
- "compatibility_date",
27408
- versionLevel.compatibility_date.value,
27409
- versionLevel.compatibility_date.fromConfig
27410
- ]);
27411
- }
27412
- if (versionLevel.compatibility_flags) {
27413
- settingsRows.push([
27414
- "compatibility_flags",
27415
- versionLevel.compatibility_flags.value.join(", "),
27416
- versionLevel.compatibility_flags.fromConfig
27417
- ]);
27418
- }
27419
- if (versionLevel.limits?.value?.cpu_ms !== void 0 || versionLevel.limits?.value?.subrequests !== void 0) {
27420
- const limitParts = [
27421
- versionLevel.limits?.value?.cpu_ms !== void 0 ? `cpu_ms: ${versionLevel.limits.value.cpu_ms}` : void 0,
27422
- versionLevel.limits?.value?.subrequests !== void 0 ? `subrequests: ${versionLevel.limits.value.subrequests}` : void 0
27423
- ].filter((value) => value !== void 0);
27424
- settingsRows.push([
27425
- "limits",
27426
- limitParts.join(", "),
27427
- versionLevel.limits.fromConfig
27428
- ]);
27429
- }
27430
- if (versionLevel.placement) {
27431
- settingsRows.push([
27432
- "placement",
27433
- versionLevel.placement.value.mode,
27434
- versionLevel.placement.fromConfig
27435
- ]);
27436
- }
27437
- if (versionLevel.cache !== void 0) {
27438
- settingsRows.push([
27439
- "cache",
27440
- versionLevel.cache.value?.enabled ? "enabled" : "disabled",
27441
- versionLevel.cache.fromConfig
27442
- ]);
27443
- }
27444
- if (settingsRows.length > 0) {
27445
- lines.push("");
27446
- lines.push(...formatAlignedRows(settingsRows));
27447
- }
27448
- if (versionLevel.assets) {
27449
- lines.push("");
27450
- lines.push(chalk6.bold(" Assets"));
27451
- const assetsRows = [];
27452
- const assets = versionLevel.assets.value;
27453
- const fromConfig = versionLevel.assets.fromConfig;
27454
- if (assets.directory) {
27455
- assetsRows.push(["directory", assets.directory, fromConfig]);
27456
- }
27457
- if (assets.binding) {
27458
- assetsRows.push(["binding", assets.binding, fromConfig]);
27459
- }
27460
- if (assets.html_handling) {
27461
- assetsRows.push(["html_handling", assets.html_handling, fromConfig]);
27462
- }
27463
- if (assets.not_found_handling) {
27464
- assetsRows.push([
27465
- "not_found_handling",
27466
- assets.not_found_handling,
27467
- fromConfig
27468
- ]);
27469
- }
27470
- if (assets.run_worker_first !== void 0) {
27471
- const value = typeof assets.run_worker_first === "boolean" ? String(assets.run_worker_first) : assets.run_worker_first.join(", ");
27472
- assetsRows.push(["run_worker_first", value, fromConfig]);
27473
- }
27474
- lines.push(...formatAlignedRows(assetsRows, " "));
27475
- }
27476
- lines.push("");
27477
- lines.push(chalk6.bold(" Bindings"));
27478
- lines.push(...formatBindings(versionLevel.env));
27479
- const hasConfigValues = settingsRows.some(([, , fromConfig]) => fromConfig) || versionLevel.assets?.fromConfig || Object.values(versionLevel.env).some((binding) => binding.fromConfig);
27480
- const footerLines = hasConfigValues ? ["", chalk6.hex("#FFA500")(`\u25C6 from ${configName}`)] : void 0;
27481
- return drawConnectedChildBox(lines, { footerLines, indent: " " });
27142
+ `${chalk6.bold("Deployment ID:")} ${deployment.id}`,
27143
+ ...formatUrlLines("Deployment", deployment.urls)
27144
+ ].join("\n");
27482
27145
  }
27483
- __name(formatDeploymentResource, "formatDeploymentResource");
27146
+ __name(formatPreviewDeploymentSummary, "formatPreviewDeploymentSummary");
27484
27147
  function logMissingPreviewsBindingsWarning(topLevelBindings, remotePreviewDefaultBindings, localPreviewBindings) {
27485
27148
  const availableBindingNames = /* @__PURE__ */ new Set([
27486
27149
  ...Object.keys(remotePreviewDefaultBindings ?? {}),
@@ -27583,18 +27246,9 @@ async function preview(accountId, args, config2, buildResult, assetsOptions) {
27583
27246
  JSON.stringify({ preview: previewResource, deployment }, null, 2)
27584
27247
  );
27585
27248
  } else {
27586
- const scriptLevel = buildMergedScriptLevel(config2, previewResource);
27587
- const versionLevel = buildMergedVersionLevel(config2, deployment);
27588
- const configName = configFileName(config2.configPath);
27589
27249
  logger.log(
27590
- formatPreviewResource(
27591
- previewResource,
27592
- scriptLevel,
27593
- isNewPreview,
27594
- configName
27595
- )
27250
+ formatPreviewDeploymentSummary(previewResource, deployment, isNewPreview)
27596
27251
  );
27597
- logger.log(formatDeploymentResource(deployment, versionLevel, configName));
27598
27252
  const topLevelBindings = getBindings(config2);
27599
27253
  if (Object.keys(topLevelBindings).length > 0) {
27600
27254
  const previewDefaults = await getWorkerPreviewDefaults(
@@ -27641,6 +27295,192 @@ This will delete all deployments associated with this Preview.`
27641
27295
  }
27642
27296
  __name(previewDelete, "previewDelete");
27643
27297
 
27298
+ // src/preview/box.ts
27299
+ var BOX = {
27300
+ topLeft: "\u256D",
27301
+ topRight: "\u256E",
27302
+ bottomLeft: "\u2570",
27303
+ bottomRight: "\u256F",
27304
+ horizontal: "\u2500",
27305
+ vertical: "\u2502",
27306
+ bottomLeftWithConnector: "\u252C",
27307
+ connectorRight: "\u2524"
27308
+ };
27309
+ function stripAnsi(str) {
27310
+ return str.replace(/\x1b\[[0-9;]*m/g, "");
27311
+ }
27312
+ __name(stripAnsi, "stripAnsi");
27313
+ function visibleLength(str) {
27314
+ return stripAnsi(str).length;
27315
+ }
27316
+ __name(visibleLength, "visibleLength");
27317
+ function padToVisibleWidth(str, width) {
27318
+ const visible = visibleLength(str);
27319
+ return str + " ".repeat(Math.max(0, width - visible));
27320
+ }
27321
+ __name(padToVisibleWidth, "padToVisibleWidth");
27322
+ function drawBox(contentLines, options = {}) {
27323
+ const lines = [...contentLines, ...options.footerLines ?? []];
27324
+ const maxContentWidth = Math.max(
27325
+ ...lines.map((line) => visibleLength(line)),
27326
+ 0
27327
+ );
27328
+ const boxWidth = maxContentWidth + 4;
27329
+ const horizontalLine = BOX.horizontal.repeat(boxWidth - 2);
27330
+ const topBorder = `${BOX.topLeft}${horizontalLine}${BOX.topRight}`;
27331
+ const bottomBorder = options.connectToChild ? `${BOX.bottomLeft}${BOX.horizontal}${BOX.bottomLeftWithConnector}${BOX.horizontal.repeat(boxWidth - 4)}${BOX.bottomRight}` : `${BOX.bottomLeft}${horizontalLine}${BOX.bottomRight}`;
27332
+ const paddedLines = lines.map((line) => {
27333
+ const paddedContent = padToVisibleWidth(line, maxContentWidth);
27334
+ return `${BOX.vertical} ${paddedContent} ${BOX.vertical}`;
27335
+ });
27336
+ return [topBorder, ...paddedLines, bottomBorder].join("\n");
27337
+ }
27338
+ __name(drawBox, "drawBox");
27339
+ function drawConnectedChildBox(contentLines, options = {}) {
27340
+ const indent = options.indent ?? " ";
27341
+ const lines = [...contentLines, ...options.footerLines ?? []];
27342
+ const maxContentWidth = lines.length > 0 ? Math.max(...lines.map((line) => visibleLength(line))) : 0;
27343
+ const boxWidth = maxContentWidth + 4;
27344
+ const horizontalLine = BOX.horizontal.repeat(boxWidth - 2);
27345
+ const topBorder = `${BOX.topLeft}${horizontalLine}${BOX.topRight}`;
27346
+ const bottomBorder = `${BOX.bottomLeft}${horizontalLine}${BOX.bottomRight}`;
27347
+ const paddedLines = lines.map((line) => {
27348
+ const paddedContent = padToVisibleWidth(line, maxContentWidth);
27349
+ return `${BOX.vertical} ${paddedContent} ${BOX.vertical}`;
27350
+ });
27351
+ const connectorIndex = options.connectorLineIndex ?? Math.floor(paddedLines.length / 2);
27352
+ const result = [];
27353
+ result.push(`${indent}${BOX.vertical}`);
27354
+ result.push(`${indent}${BOX.vertical} ${topBorder}`);
27355
+ paddedLines.forEach((line, index) => {
27356
+ if (index === connectorIndex) {
27357
+ result.push(
27358
+ `${indent}${BOX.bottomLeft}${BOX.horizontal}${BOX.connectorRight}${line.slice(1)}`
27359
+ );
27360
+ } else if (index < connectorIndex) {
27361
+ result.push(`${indent}${BOX.vertical} ${line}`);
27362
+ } else {
27363
+ result.push(`${indent} ${line}`);
27364
+ }
27365
+ });
27366
+ result.push(`${indent} ${bottomBorder}`);
27367
+ return result.join("\n");
27368
+ }
27369
+ __name(drawConnectedChildBox, "drawConnectedChildBox");
27370
+
27371
+ // src/preview/format.ts
27372
+ var CONFIG_MARKER = chalk6.hex("#FFA500")("\u25C6");
27373
+ function getFriendlyBindingType(bindingType) {
27374
+ return getBindingTypeFriendlyName(
27375
+ bindingType
27376
+ );
27377
+ }
27378
+ __name(getFriendlyBindingType, "getFriendlyBindingType");
27379
+ function formatAlignedRows(rows, indent = " ") {
27380
+ const labelWidth = Math.max(...rows.map(([label]) => label.length));
27381
+ const valueWidth = Math.max(...rows.map(([, value]) => value.length));
27382
+ return rows.map(([label, value, fromConfig]) => {
27383
+ const marker = fromConfig ? CONFIG_MARKER : " ";
27384
+ const coloredLabel = chalk6.cyan(padToVisibleWidth(label, labelWidth));
27385
+ return `${indent}${coloredLabel} ${padToVisibleWidth(
27386
+ value,
27387
+ valueWidth
27388
+ )} ${marker}`;
27389
+ });
27390
+ }
27391
+ __name(formatAlignedRows, "formatAlignedRows");
27392
+ function formatBindings(env, indent = " ", options = {}) {
27393
+ const showSourceMarker = options.showSourceMarker ?? true;
27394
+ const entries = Object.entries(env);
27395
+ if (entries.length === 0) {
27396
+ return [`${indent}${chalk6.dim("(none)")}`];
27397
+ }
27398
+ const nameWidth = Math.max(...entries.map(([name]) => name.length));
27399
+ const typeWidth = Math.max(
27400
+ ...entries.map(
27401
+ ([, binding]) => visibleLength(getFriendlyBindingType(binding.type))
27402
+ )
27403
+ );
27404
+ const valueWidth = Math.max(
27405
+ ...entries.map(([, binding]) => getBindingValue(binding).length)
27406
+ );
27407
+ return entries.map(([name, binding]) => {
27408
+ const value = getBindingValue(binding);
27409
+ const friendlyType = getFriendlyBindingType(binding.type);
27410
+ const coloredName = chalk6.cyan(padToVisibleWidth(name, nameWidth));
27411
+ const dimType = chalk6.dim(padToVisibleWidth(friendlyType, typeWidth));
27412
+ if (showSourceMarker) {
27413
+ const marker = binding.fromConfig ? CONFIG_MARKER : " ";
27414
+ return `${indent}${coloredName} ${dimType} ${padToVisibleWidth(
27415
+ value,
27416
+ valueWidth
27417
+ )} ${marker}`;
27418
+ }
27419
+ return `${indent}${coloredName} ${dimType} ${padToVisibleWidth(
27420
+ value,
27421
+ valueWidth
27422
+ )}`;
27423
+ });
27424
+ }
27425
+ __name(formatBindings, "formatBindings");
27426
+ function formatPreviewsSettings(workerName, previewDefaults) {
27427
+ const lines = [];
27428
+ lines.push(`${chalk6.bold.hex("#FFA500")("Worker:")} ${workerName}`);
27429
+ lines.push("");
27430
+ lines.push(` ${chalk6.bold.underline("Previews settings")}`);
27431
+ lines.push("");
27432
+ const settingsRows = [];
27433
+ if (previewDefaults.observability && typeof previewDefaults.observability === "object") {
27434
+ const enabledLabel = previewDefaults.observability.enabled ? "enabled" : "disabled";
27435
+ const sampling = typeof previewDefaults.observability.head_sampling_rate === "number" ? `, ${previewDefaults.observability.head_sampling_rate.toFixed(
27436
+ 1
27437
+ )} sampling` : "";
27438
+ settingsRows.push(["observability", `${enabledLabel}${sampling}`]);
27439
+ }
27440
+ if (typeof previewDefaults.logpush === "boolean") {
27441
+ settingsRows.push([
27442
+ "logpush",
27443
+ previewDefaults.logpush ? "enabled" : "disabled"
27444
+ ]);
27445
+ }
27446
+ if (typeof previewDefaults.limits?.cpu_ms === "number" || typeof previewDefaults.limits?.subrequests === "number") {
27447
+ const limitParts = [
27448
+ typeof previewDefaults.limits?.cpu_ms === "number" ? `cpu_ms: ${previewDefaults.limits.cpu_ms}` : void 0,
27449
+ typeof previewDefaults.limits?.subrequests === "number" ? `subrequests: ${previewDefaults.limits.subrequests}` : void 0
27450
+ ].filter((value) => value !== void 0);
27451
+ settingsRows.push(["limits", limitParts.join(", ")]);
27452
+ }
27453
+ if (typeof previewDefaults.placement?.mode === "string") {
27454
+ settingsRows.push(["placement", previewDefaults.placement.mode]);
27455
+ }
27456
+ if (previewDefaults.cache !== void 0) {
27457
+ settingsRows.push([
27458
+ "cache",
27459
+ previewDefaults.cache.enabled ? "enabled" : "disabled"
27460
+ ]);
27461
+ }
27462
+ if (settingsRows.length > 0) {
27463
+ const labelWidth = Math.max(...settingsRows.map(([label]) => label.length));
27464
+ for (const [label, value] of settingsRows) {
27465
+ lines.push(
27466
+ ` ${chalk6.cyan(padToVisibleWidth(label, labelWidth))} ${value}`
27467
+ );
27468
+ }
27469
+ }
27470
+ lines.push("");
27471
+ lines.push(chalk6.bold(" Bindings"));
27472
+ const env = Object.fromEntries(
27473
+ Object.entries(previewDefaults.env ?? {}).map(([name, binding]) => [
27474
+ name,
27475
+ { ...binding, fromConfig: false }
27476
+ ])
27477
+ );
27478
+ lines.push(...formatBindings(env));
27479
+ lines.push("");
27480
+ return drawBox(lines);
27481
+ }
27482
+ __name(formatPreviewsSettings, "formatPreviewsSettings");
27483
+
27644
27484
  // src/preview/merge-deep.ts
27645
27485
  function mergeDeep(target, source) {
27646
27486
  if (typeof target !== "object" || target === null) {
@@ -27758,4 +27598,4 @@ __name(previewSettingsUpdate, "previewSettingsUpdate");
27758
27598
  * THE SOFTWARE.
27759
27599
  */
27760
27600
 
27761
- export { ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE, EXPORTS_RECONCILIATION_ERROR_CODE, INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE, INVALID_INHERIT_BINDING_CODE, NoInputError, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_CRON_REQUIRES_PAID_PLAN_CODE, WORKFLOW_NOT_FOUND_CODE, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags, assemblePreviewDefaults, assemblePreviewScriptSettings, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, collectPackageDependencies, confirmLatestDeploymentOverwrite, createDeployment, createPreview, createPreviewDeployment, createTruncatedAlias, decodeJwtPayload, deletePreview, deletePullConsumer, deleteWorkerConsumer, deploy, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, drawBox, drawConnectedChildBox, editPreview, editWorkerPreviewDefaults, ensureQueuesExistByConfig, extractConfigBindings, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, formatAlignedRows, formatBindings, formatPreviewsSettings, generatePreviewAlias, getBindingValue, getBranchName2 as getBranchName, getConfigPatch, getDeployConfirmFunction, getEdgeKvUploadConcurrency, getHeadCommitMessage, getHeadCommitRef, getMigrationsToUpload, getPreview, getPreviewDeployment, getQueue, getRemoteConfigDiff, getSettings, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getWorkerPreviewDefaults, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isExportsReconciliationErrorDetails, isJwtExpired, isModifiedDiffValue, isNonDestructive, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, mergeDeep, padToVisibleWidth, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, postConsumer, preview, previewDelete, previewSettingsGet, previewSettingsUpdate, printBindings, printBundleSize, printVersions, provisionBindings, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderBindingDependsOnExportError, renderExportsReconciliationError, renderExportsReconciliationSuccess, renderInconsistentExportsAcrossVersionsError, renderRoute, resolveAssetOptions, resolveDoLifecyclePayload, resolveExportsUploadPayload, resolveWorkerName, sanitizeBranchName, shouldUseCIMetadataFallback, stripAnsi, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, validateEventTriggerTargets, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, visibleLength, warnOnErrorUpdatingServiceAndEnvironmentTags, warnOrError, workerNotFoundErrorMessage };
27601
+ export { ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE, EXPORTS_RECONCILIATION_ERROR_CODE, INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE, INVALID_INHERIT_BINDING_CODE, NoInputError, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_CRON_REQUIRES_PAID_PLAN_CODE, WORKFLOW_NOT_FOUND_CODE, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags, assemblePreviewDefaults, assemblePreviewScriptSettings, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, collectPackageDependencies, confirmLatestDeploymentOverwrite, createDeployment, createPreview, createPreviewDeployment, createTruncatedAlias, decodeJwtPayload, deletePreview, deletePullConsumer, deleteWorkerConsumer, deploy, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, drawBox, drawConnectedChildBox, editPreview, editWorkerPreviewDefaults, ensureQueuesExistByConfig, extractConfigBindings, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, formatAlignedRows, formatBindings, formatPreviewsSettings, generatePreviewAlias, getBindingValue, getBranchName2 as getBranchName, getConfigPatch, getDeployConfirmFunction, getEdgeKvUploadConcurrency, getHeadCommitMessage, getHeadCommitRef, getMigrationsToUpload, getPreview, getPreviewBaseConfig, getPreviewDeployment, getQueue, getRemoteConfigDiff, getSettings, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getWorkerPreviewDefaults, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isExportsReconciliationErrorDetails, isJwtExpired, isModifiedDiffValue, isNonDestructive, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, mergeDeep, padToVisibleWidth, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, patchPreviewBaseConfig, patchPreviewDeployment, postConsumer, preview, previewDelete, previewSettingsGet, previewSettingsUpdate, printBindings, printBundleSize, printVersions, provisionBindings, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderBindingDependsOnExportError, renderExportsReconciliationError, renderExportsReconciliationSuccess, renderInconsistentExportsAcrossVersionsError, renderRoute, resolveAssetOptions, resolveDoLifecyclePayload, resolveExportsUploadPayload, resolveWorkerName, sanitizeBranchName, shouldUseCIMetadataFallback, stripAnsi, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, validateEventTriggerTargets, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, visibleLength, warnOnErrorUpdatingServiceAndEnvironmentTags, warnOrError, workerNotFoundErrorMessage };