@binaryandthread/cli 0.4.5 → 0.4.7

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/README.md CHANGED
@@ -115,7 +115,7 @@ skips the interactive confirm so it never hangs in CI. Field shapes (stable, saf
115
115
  | `bt checkout` | `{ status: "placed"\|"timeout"\|"expired", order_id?, display_id?, total?, currency?, checkout_url? }` |
116
116
  | `bt region` | `{ region, currency, matched, home }` · `--list` → `{ regions: [{ currency, countries[] }] }` |
117
117
  | `bt whoami` | `{ authenticated, tier, commits, standing_pct, token_expires_at, token_expired }` |
118
- | `bt order <id>` | `{ display_id, status, fulfillment_status?, tracking? }` |
118
+ | `bt order <id>` | `{ display_id, stage: "committed"\|"shipped"\|"delivered"\|"reverted", total, currency }` (committed = placed, not shipped yet) |
119
119
 
120
120
  **Errors** (`--json`) come back as `{ "error": { "code", "type", "message" } }` and the process
121
121
  exits with a distinct code so CI/agents can branch:
package/dist/bin.js CHANGED
@@ -36,6 +36,7 @@ import {
36
36
  isCartTaxInclusive,
37
37
  lineColour,
38
38
  ok,
39
+ orderStage,
39
40
  priceLine,
40
41
  printResult,
41
42
  productColours,
@@ -55,7 +56,7 @@ import {
55
56
  versionLine,
56
57
  warn,
57
58
  working
58
- } from "./chunk-PG7YCPAN.js";
59
+ } from "./chunk-CE324N5B.js";
59
60
  import {
60
61
  __require
61
62
  } from "./chunk-7OCVIDC7.js";
@@ -104,7 +105,7 @@ function makeLogger(debug, write = (s) => process.stderr.write(s)) {
104
105
  }
105
106
 
106
107
  // src/version.ts
107
- var VERSION = "0.4.5";
108
+ var VERSION = "0.4.7";
108
109
 
109
110
  // src/eggs.ts
110
111
  function teapot() {
@@ -524,7 +525,7 @@ function registerBrowse(program, makeClient2, loadConfig2) {
524
525
  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) => {
525
526
  const { json, brand } = resolveOutput(program);
526
527
  if (opts.pick && !json && brand.color && process.stdout.isTTY && process.stdin.isTTY) {
527
- const { runInteractiveBrowse } = await import("./interactive-HI3LDK5U.js");
528
+ const { runInteractiveBrowse } = await import("./interactive-7GY3BVQ6.js");
528
529
  const handled = await runInteractiveBrowse(makeClient2(), loadConfig2(), { branch: opts.branch, brand });
529
530
  if (handled) return;
530
531
  }
@@ -1091,13 +1092,11 @@ function registerCheckout(program, makeClient2, loadConfig2) {
1091
1092
  }
1092
1093
 
1093
1094
  // src/commands/order.ts
1094
- var STAGES = ["staged", "committed", "printed", "shipped", "delivered"];
1095
+ var STAGES = ["staged", "committed", "shipped", "delivered"];
1096
+ var DELIVERED = STAGES.length - 1;
1095
1097
  function stageIndex(o) {
1096
- const f = (o.fulfillment_status ?? "").toLowerCase();
1097
- if (f.includes("delivered")) return 4;
1098
- if (f.includes("shipped")) return 3;
1099
- if (f.includes("fulfilled") || f.includes("printed") || f.includes("partially_shipped")) return 2;
1100
- return 1;
1098
+ const stage = orderStage(o);
1099
+ return stage === "reverted" ? -1 : STAGES.indexOf(stage);
1101
1100
  }
1102
1101
  function timelineGraph(idx) {
1103
1102
  const dots = STAGES.map((_s, i) => i <= idx ? "\u25CF" : "\u25CB").join("\u2500\u2500");
@@ -1130,16 +1129,22 @@ async function runOrder(client, config, args) {
1130
1129
  const itemLabel = first ? `${first.title ?? "item"}${first.variant_title ? ` \xB7 ${first.variant_title}` : ""}` : "your order";
1131
1130
  const style = brandOf(args);
1132
1131
  const lines = [];
1133
- lines.push(`${display} ${itemLabel} ${cyan(style, timelineGraph(idx))} ${STAGES[idx]}`);
1134
- lines.push(` ${STAGES.join(" \u2192 ")}${idx === 4 ? " \u{1F389}" : ""}`);
1132
+ const stageWord = idx < 0 ? "reverted" : STAGES[idx];
1133
+ if (idx < 0) {
1134
+ lines.push(`${display} ${itemLabel} reverted`);
1135
+ lines.push(` this order was canceled or refunded. nothing ships.`);
1136
+ } else {
1137
+ lines.push(`${display} ${itemLabel} ${cyan(style, timelineGraph(idx))} ${stageWord}`);
1138
+ lines.push(` ${STAGES.join(" \u2192 ")}${idx === DELIVERED ? " \u{1F389}" : ""}`);
1139
+ }
1135
1140
  lines.push(` total ${cyan(style, total)}${taxSuffix(orderTaxInclusive)}`);
1136
1141
  return {
1137
1142
  lines,
1138
- json: args.json ? { display_id: display, stage: STAGES[idx], total: o.total ?? null, currency: o.currency_code ?? null } : void 0
1143
+ json: args.json ? { display_id: display, stage: stageWord, total: o.total ?? null, currency: o.currency_code ?? null } : void 0
1139
1144
  };
1140
1145
  }
1141
1146
  function registerOrder(program, makeClient2, loadConfig2) {
1142
- program.command("order").argument("<id>", "the order number (display id)").description("track one order: staged \u2192 committed \u2192 printed \u2192 shipped \u2192 delivered.").action(async (id) => {
1147
+ program.command("order").argument("<id>", "the order number (display id)").description("track one order: staged \u2192 committed \u2192 shipped \u2192 delivered.").action(async (id) => {
1143
1148
  const { json, brand } = resolveOutput(program);
1144
1149
  const res = await runOrder(makeClient2(), loadConfig2(), { displayId: id, json, brand });
1145
1150
  printResult(res, json);
@@ -1192,16 +1197,8 @@ function registerToken(program) {
1192
1197
  }
1193
1198
 
1194
1199
  // src/commands/log-graph.ts
1195
- function orderStage(o) {
1196
- const status = (o.status ?? "").toLowerCase();
1197
- if (status.includes("cancel") || status.includes("refund") || status.includes("revert")) {
1198
- return "reverted";
1199
- }
1200
- const f = (o.fulfillment_status ?? "").toLowerCase();
1201
- if (f.includes("delivered")) return "delivered";
1202
- if (f.includes("shipped")) return "shipped";
1203
- if (f.includes("fulfilled") || f.includes("printed") || f.includes("partially")) return "printed";
1204
- return "committed";
1200
+ function orderStage2(o) {
1201
+ return orderStage(o);
1205
1202
  }
1206
1203
  function shortHash(o) {
1207
1204
  const seed = `${o.display_id ?? ""}:${o.created_at ?? ""}`;
@@ -1219,19 +1216,19 @@ function label(o) {
1219
1216
  return `${first.title ?? "order"}${first.variant_title ? ` \xB7 ${first.variant_title}` : ""}`;
1220
1217
  }
1221
1218
  function hasLiveHead(orders) {
1222
- return orders.some((o) => orderStage(o) !== "reverted");
1219
+ return orders.some((o) => orderStage2(o) !== "reverted");
1223
1220
  }
1224
1221
  function renderOneline(orders, style) {
1225
1222
  if (orders.length === 0) return [];
1226
1223
  const live = hasLiveHead(orders);
1227
- const headIdx = live ? orders.findIndex((o) => orderStage(o) !== "reverted") : -1;
1224
+ const headIdx = live ? orders.findIndex((o) => orderStage2(o) !== "reverted") : -1;
1228
1225
  const lines = [];
1229
1226
  if (!live) {
1230
1227
  lines.push(dim(style, "(detached HEAD) you have no committed fits. literally nothing to wear. we don't judge."));
1231
1228
  }
1232
1229
  orders.forEach((o, i) => {
1233
1230
  const hash = shortHash(o);
1234
- const stage = orderStage(o);
1231
+ const stage = orderStage2(o);
1235
1232
  const ref = i === headIdx ? "(HEAD -> main) " : "";
1236
1233
  const tail = stage === "delivered" ? "delivered \u{1F389}" : stage;
1237
1234
  lines.push(`${hash} ${ref}${label(o).padEnd(34)} ${tail}`);
@@ -1241,14 +1238,14 @@ function renderOneline(orders, style) {
1241
1238
  function renderGraph(orders, style) {
1242
1239
  if (orders.length === 0) return [];
1243
1240
  const live = hasLiveHead(orders);
1244
- const headIdx = live ? orders.findIndex((o) => orderStage(o) !== "reverted") : -1;
1241
+ const headIdx = live ? orders.findIndex((o) => orderStage2(o) !== "reverted") : -1;
1245
1242
  const lines = [];
1246
1243
  if (!live) {
1247
1244
  lines.push(dim(style, "(detached HEAD) no committed fits. literally nothing to wear. we don't judge."));
1248
1245
  }
1249
1246
  orders.forEach((o, i) => {
1250
1247
  const hash = shortHash(o);
1251
- const stage = orderStage(o);
1248
+ const stage = orderStage2(o);
1252
1249
  const ref = i === headIdx ? " (HEAD -> main)" : "";
1253
1250
  const node = stage === "delivered" ? green(style, "*") : "*";
1254
1251
  const tail = stage === "delivered" ? `${stage} ${green(style, "\u{1F389}")}` : stage;
@@ -1262,7 +1259,7 @@ function renderGraph(orders, style) {
1262
1259
  function renderFlat(orders) {
1263
1260
  return orders.map((o) => {
1264
1261
  const display = String(o.display_id ?? "");
1265
- return `${display.padEnd(8)} ${label(o).padEnd(36)} ${orderStage(o)}`;
1262
+ return `${display.padEnd(8)} ${label(o).padEnd(36)} ${orderStage2(o)}`;
1266
1263
  });
1267
1264
  }
1268
1265