@binaryandthread/cli 0.1.4 → 0.1.6

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
@@ -35,18 +35,20 @@ import {
35
35
  ok,
36
36
  printResult,
37
37
  productColours,
38
+ productLore,
38
39
  redact,
39
40
  registerStage,
40
41
  registerView,
41
42
  resolveLineItemRef,
42
43
  resolveOutput,
44
+ resolveProduct,
43
45
  rule,
44
46
  runStage,
45
47
  stageMarker,
46
48
  versionLine,
47
49
  warn,
48
50
  working
49
- } from "./chunk-V7YRJ67J.js";
51
+ } from "./chunk-CA3GGJGF.js";
50
52
  import {
51
53
  __require
52
54
  } from "./chunk-7OCVIDC7.js";
@@ -75,7 +77,7 @@ function makeLogger(debug, write = (s) => process.stderr.write(s)) {
75
77
  }
76
78
 
77
79
  // src/version.ts
78
- var VERSION = "0.1.4";
80
+ var VERSION = "0.1.6";
79
81
 
80
82
  // src/eggs.ts
81
83
  function teapot() {
@@ -354,7 +356,7 @@ function registerBrowse(program, makeClient2, loadConfig2) {
354
356
  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) => {
355
357
  const { json, brand } = resolveOutput(program);
356
358
  if (opts.pick && !json && brand.color && process.stdout.isTTY && process.stdin.isTTY) {
357
- const { runInteractiveBrowse } = await import("./interactive-GY4AK7D2.js");
359
+ const { runInteractiveBrowse } = await import("./interactive-HKGPS4PX.js");
358
360
  const handled = await runInteractiveBrowse(makeClient2(), loadConfig2(), { branch: opts.branch, brand });
359
361
  if (handled) return;
360
362
  }
@@ -1654,6 +1656,43 @@ function registerReport(program, makeClient2) {
1654
1656
  });
1655
1657
  }
1656
1658
 
1659
+ // src/commands/blame.ts
1660
+ async function runBlame(client, config, args) {
1661
+ const slug = (args.handle ?? "").trim();
1662
+ if (!slug) {
1663
+ return { lines: blame().split("\n") };
1664
+ }
1665
+ const region = await client.resolveRegion(config.region);
1666
+ const picked = await resolveProduct(client, region, slug);
1667
+ const product = picked.product;
1668
+ if (!product) {
1669
+ return { lines: blame(slug).split("\n") };
1670
+ }
1671
+ const { handle } = displayName(product);
1672
+ const lore = productLore(product);
1673
+ const lines = [];
1674
+ if (picked.fuzzy && handle !== slug) {
1675
+ lines.push(working(`matched "${handle}" from "${slug}"`));
1676
+ }
1677
+ if (!lore.text) {
1678
+ lines.push(...blame(handle).split("\n"));
1679
+ return { lines, json: args.json ? { handle, lore: null } : void 0 };
1680
+ }
1681
+ lines.push(`blame ${handle}`);
1682
+ lines.push(` ${lore.text}`);
1683
+ for (const s of lore.sources) {
1684
+ lines.push(` source ${s.label} (${s.url})`);
1685
+ }
1686
+ return { lines, json: args.json ? { handle, lore } : void 0 };
1687
+ }
1688
+ function registerBlame(program, makeClient2, loadConfig2) {
1689
+ program.command("blame", { hidden: true }).argument("[slug]", "a design \u2014 a slug, a bt browse number, or a fuzzy hint").description("who's responsible for a design \u2014 its lore + sources (git blame, for motifs).").action(async (slug) => {
1690
+ const { json, brand } = resolveOutput(program);
1691
+ const res = await runBlame(makeClient2(), loadConfig2(), { handle: slug, json, brand });
1692
+ printResult(res, json);
1693
+ });
1694
+ }
1695
+
1657
1696
  // src/bin.ts
1658
1697
  function makeClient() {
1659
1698
  const { baseUrl, publishableKey } = resolveClientConfig();
@@ -1709,6 +1748,7 @@ function registerCommands(program) {
1709
1748
  registerToken(program);
1710
1749
  registerDoctor(program);
1711
1750
  registerReport(program, makeClient);
1751
+ registerBlame(program, makeClient, loadConfig);
1712
1752
  registerCart(program, makeClient, loadConfig);
1713
1753
  registerCheckout(program, makeClient, loadConfig);
1714
1754
  registerOrder(program, makeClient, loadConfig);
@@ -1749,7 +1789,6 @@ function registerEggs(program) {
1749
1789
  program.command("push", { hidden: true }).allowUnknownOption().argument("[args...]").action(() => print(gitPush()));
1750
1790
  program.command("pull", { hidden: true }).allowUnknownOption().argument("[args...]").action(() => print(gitPull()));
1751
1791
  program.command("reflog", { hidden: true }).allowUnknownOption().argument("[args...]").action(() => print(gitReflog()));
1752
- program.command("blame", { hidden: true }).argument("[slug]", "a design slug to blame").description("who's responsible for all this \u2014 provenance + lore.").action((slug) => print(blame(slug)));
1753
1792
  program.command("fortune").description("a coding fortune. real aphorisms only.").action(() => {
1754
1793
  const seed = Math.floor(Date.now() / 1e3) % FORTUNES.length;
1755
1794
  print(fortune(seed));