@binaryandthread/cli 0.4.1 → 0.4.3

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/bin.js CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  StoreClient,
20
20
  box,
21
21
  brandOf,
22
+ cartMoneyRows,
22
23
  colourMarker,
23
24
  contributionBar,
24
25
  cyan,
@@ -54,7 +55,7 @@ import {
54
55
  versionLine,
55
56
  warn,
56
57
  working
57
- } from "./chunk-42NDSW24.js";
58
+ } from "./chunk-VO3TABLK.js";
58
59
  import {
59
60
  __require
60
61
  } from "./chunk-7OCVIDC7.js";
@@ -103,7 +104,7 @@ function makeLogger(debug, write = (s) => process.stderr.write(s)) {
103
104
  }
104
105
 
105
106
  // src/version.ts
106
- var VERSION = "0.4.1";
107
+ var VERSION = "0.4.3";
107
108
 
108
109
  // src/eggs.ts
109
110
  function teapot() {
@@ -523,7 +524,7 @@ function registerBrowse(program, makeClient2, loadConfig2) {
523
524
  program.command("browse").alias("ls").description("list what's in stock on a branch.").option("--branch <branch>", "main (live) or next (terminal-only drops)").option("--pick", "opt into the arrow-key picker (default is the numbered table \u2014 use bt stage <n>)").option("--plain", "force the static table (the default; kept for back-compat)").action(async (opts) => {
524
525
  const { json, brand } = resolveOutput(program);
525
526
  if (opts.pick && !json && brand.color && process.stdout.isTTY && process.stdin.isTTY) {
526
- const { runInteractiveBrowse } = await import("./interactive-CVHHGMCQ.js");
527
+ const { runInteractiveBrowse } = await import("./interactive-4NOJ3LFW.js");
527
528
  const handled = await runInteractiveBrowse(makeClient2(), loadConfig2(), { branch: opts.branch, brand });
528
529
  if (handled) return;
529
530
  }
@@ -746,8 +747,18 @@ async function runCart(client, config, args) {
746
747
  lines.push(formatCartLine(item, i, cart.currency_code, style));
747
748
  });
748
749
  if (cart.total != null) {
749
- const shipNote = (cart.shipping_methods ?? []).length > 0 ? "" : dim(style, " (excl. shipping \u2014 calculated at checkout)");
750
- lines.push(` total ${cyan(style, fmtPrice(cart.total, cart.currency_code))}${taxSuffix(isCartTaxInclusive(cart))}${shipNote}`);
750
+ for (const row of cartMoneyRows({
751
+ itemTotal: cart.item_total,
752
+ discountTotal: cart.discount_total,
753
+ shippingTotal: cart.shipping_total,
754
+ hasShippingMethod: (cart.shipping_methods ?? []).length > 0,
755
+ total: cart.total
756
+ })) {
757
+ const value = row.display ?? `${row.kind === "discount" ? "\u2212" : ""}${fmtPrice(row.amount, cart.currency_code)}`;
758
+ lines.push(
759
+ row.kind === "total" ? ` ${row.label.padEnd(8)} ${cyan(style, value)}${taxSuffix(isCartTaxInclusive(cart))}` : dim(style, ` ${row.label.padEnd(8)} ${value}${row.note ? ` (${row.note})` : ""}`)
760
+ );
761
+ }
751
762
  }
752
763
  lines.push(" remove one \u2192 bt unstage <#> \xB7 commit \u2192 bt commit");
753
764
  }
@@ -756,6 +767,9 @@ async function runCart(client, config, args) {
756
767
  json: args.json ? {
757
768
  cart_id: cart.id,
758
769
  items: cart.items ?? [],
770
+ item_total: cart.item_total ?? null,
771
+ discount_total: cart.discount_total ?? null,
772
+ shipping_total: cart.shipping_total ?? null,
759
773
  total: cart.total ?? null,
760
774
  total_excludes_shipping: (cart.shipping_methods ?? []).length === 0
761
775
  } : void 0
@@ -884,12 +898,26 @@ async function runCheckout(client, config, args, deps) {
884
898
  ` ${(li.title ?? li.product_title ?? "item").toString()}${colourTag} \xB7 qty ${li.quantity}` + (li.total != null ? ` ${cyan(style, fmtPrice(li.total, cart.currency_code ?? region.currency_code))}` : "")
885
899
  );
886
900
  }
887
- if (mint.discount && mint.discount.amount > 0) {
888
- reviewLines.push(
889
- dim(style, ` dev channel \u2212${fmtPrice(mint.discount.amount, currency)} (${mint.discount.pct}% \u2014 for shopping the terminal)`)
890
- );
901
+ const moneyRows = cartMoneyRows({
902
+ itemTotal: shippedCart?.item_total ?? cart.item_total,
903
+ // The dev-channel 10% is applied server-side at MINT, so it lives on the mint response, never on
904
+ // the cart — cart.discount_total is 0 on a terminal cart by design.
905
+ discountTotal: mint.discount?.amount,
906
+ discountLabel: "dev channel",
907
+ discountNote: mint.discount ? `${mint.discount.pct}% \u2014 for shopping the terminal` : null,
908
+ shippingTotal: shippedCart?.shipping_total,
909
+ hasShippingMethod: (shippedCart?.shipping_methods ?? []).length > 0,
910
+ total: mint.total ?? shippedCart?.total ?? cart.total
911
+ });
912
+ for (const row of moneyRows) {
913
+ const value = row.display ?? `${row.kind === "discount" ? "\u2212" : ""}${fmtPrice(row.amount, currency)}`;
914
+ const note = row.note ? ` (${row.note})` : "";
915
+ if (row.kind === "total") {
916
+ reviewLines.push(` ${row.label.padEnd(8)} ${cyan(style, value)}${taxSuffix(taxIncl)}`);
917
+ } else {
918
+ reviewLines.push(dim(style, ` ${row.label.padEnd(8)} ${value}${note}`));
919
+ }
891
920
  }
892
- reviewLines.push(` total ${cyan(style, totalLine)}${taxSuffix(taxIncl)}`);
893
921
  const print = deps.print ?? ((line) => process.stdout.write(line + "\n"));
894
922
  for (const line of reviewLines) {
895
923
  print(line);