@binaryandthread/cli 0.4.8 → 0.4.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.
@@ -624,7 +624,8 @@ function supplierOf(p) {
624
624
  return v === "gelato" || v === "printful" ? v : null;
625
625
  }
626
626
  var PRINTFUL_BLANK_COLOURS = {
627
- "ascolour-5082": ["black", "white"]
627
+ "ascolour-5082": ["black", "white", "coal", "eucalyptus", "bone"]
628
+ // TB124
628
629
  };
629
630
  var PRINTFUL_BLANK_SIZES = {
630
631
  "ascolour-5082": ["s", "m", "l", "xl", "2xl"]
@@ -758,7 +759,7 @@ function resolveVariant(p, opts) {
758
759
  const gate = gateFit(p, fit);
759
760
  const supplier = supplierOf(p);
760
761
  const colours = coloursFor(p, fit, opts.countryCode);
761
- const colour = (opts.colour ?? "").trim().toLowerCase() || (colours[0] ?? null);
762
+ const colour = colourKey(opts.colour ?? "") || (colours[0] ?? null);
762
763
  if (gate && colour && opts.countryCode !== void 0 && !colourBuyable(gate, colour, opts.countryCode, supplier)) {
763
764
  return { ok: false, reason: "fit_unavailable", fit: gate, colour };
764
765
  }
@@ -788,10 +789,26 @@ var FIT_TOKEN = /^(regular|oversize)$/i;
788
789
  function titleSegments(title) {
789
790
  return (title ?? "").split("/").map((s) => s.trim()).filter(Boolean);
790
791
  }
791
- function displayColour(colour) {
792
+ var COLOUR_LABELS = { black: "Faded Black", white: "Faded White", coal: "Faded Coal", eucalyptus: "Faded Eucalyptus", bone: "Faded Bone" };
793
+ function colourLabel(colour) {
792
794
  const c = colour.trim();
793
795
  if (!c) return c;
794
- return c.charAt(0).toUpperCase() + c.slice(1).toLowerCase();
796
+ return COLOUR_LABELS[c.toLowerCase()] ?? c.charAt(0).toUpperCase() + c.slice(1).toLowerCase();
797
+ }
798
+ function colourKey(colour) {
799
+ const c = colour.trim().toLowerCase();
800
+ const key = Object.entries(COLOUR_LABELS).find(([, label]) => label.toLowerCase() === c)?.[0];
801
+ return key ?? c;
802
+ }
803
+ function labelVariantTitle(title) {
804
+ return (title ?? "").split("/").map((seg) => {
805
+ const t = seg.trim();
806
+ const k = t.toLowerCase();
807
+ return Object.prototype.hasOwnProperty.call(COLOUR_LABELS, k) ? colourLabel(t) : t;
808
+ }).join(" / ");
809
+ }
810
+ function displayColour(colour) {
811
+ return colourLabel(colour);
795
812
  }
796
813
  function variantColour(v) {
797
814
  const opt = (v.options ?? []).find(
@@ -840,7 +857,7 @@ function findVariant(p, opts = {}) {
840
857
  }
841
858
  const variants = (p.variants ?? []).filter((v) => fit === null || variantFit(v) === fit);
842
859
  const size = opts.size?.trim().toLowerCase();
843
- const colour = opts.colour?.trim().toLowerCase();
860
+ const colour = opts.colour ? colourKey(opts.colour) : void 0;
844
861
  const sizeMatches = (v) => {
845
862
  if (!size) return true;
846
863
  return (sizeOfVariant(v) ?? "").toLowerCase() === size || (v.title ?? "").toLowerCase() === size;
@@ -1249,7 +1266,7 @@ function colourSwatch(colour) {
1249
1266
  function colourMarker(colours) {
1250
1267
  if (colours.length === 0) return "";
1251
1268
  const swatches = colours.map((c) => colourSwatch(c)).join("");
1252
- const names = colours.join("/");
1269
+ const names = colours.map((c) => colourLabel(c)).join(" / ");
1253
1270
  return `${swatches} ${names}`;
1254
1271
  }
1255
1272
 
@@ -1327,7 +1344,7 @@ function formatCartLine(item, index, currency, brand) {
1327
1344
  const idTag = item.id ? dimTag(style, ` (#${shortItemId(item.id)})`) : "";
1328
1345
  const colour = lineColour(item);
1329
1346
  const fit = lineFit(item);
1330
- const tags = [colour, fit ? fitLabel(fit).toLowerCase() : null].filter(Boolean).join(", ");
1347
+ const tags = [colour ? colourLabel(colour).toLowerCase() : null, fit ? fitLabel(fit).toLowerCase() : null].filter(Boolean).join(", ");
1331
1348
  const colourTag = tags ? ` \xB7 ${tags}` : "";
1332
1349
  const price = item.total != null ? ` ${accentPrice(style, fmtPrice(item.total, currency))}` : "";
1333
1350
  return ` ${ref} ${title}${colourTag}${idTag} \xB7 qty ${item.quantity}${price}`;
@@ -1590,13 +1607,13 @@ async function runView(client, config, args) {
1590
1607
  lines.push(` ${s.key.padEnd(9)}${s.value}`);
1591
1608
  }
1592
1609
  if (colours.length > 0 || unavailable.length > 0) {
1593
- lines.push(` colours ${colours.map((c) => `${colourSwatch(c)} ${c}`).join(" \xB7 ")}`);
1610
+ lines.push(` colours ${colours.map((c) => `${colourSwatch(c)} ${colourLabel(c)}`).join(" \xB7 ")}`);
1594
1611
  for (const c of colours) {
1595
1612
  const sizes = sortSizes(sizesFor(product, fit, c, countryCode));
1596
- lines.push(` ${colourSwatch(c)} ${c.padEnd(6)} ${sizes.join(" ")}`);
1613
+ lines.push(` ${colourSwatch(c)} ${colourLabel(c).padEnd(12)} ${sizes.join(" ")}`);
1597
1614
  }
1598
1615
  for (const c of unavailable) {
1599
- lines.push(dim(style, ` ${colourSwatch(c)} ${c.padEnd(6)} not available where you ship (${countryCode ?? "your region"})`));
1616
+ lines.push(dim(style, ` ${colourSwatch(c)} ${colourLabel(c).padEnd(12)} not available where you ship (${countryCode ?? "your region"})`));
1600
1617
  }
1601
1618
  } else {
1602
1619
  const sizes = sortSizes((product.variants ?? []).map((v) => v.title ?? "?"));
@@ -1611,13 +1628,13 @@ async function runView(client, config, args) {
1611
1628
  }
1612
1629
  let imageUrl = product.thumbnail ?? null;
1613
1630
  let blackNote = null;
1614
- const wanted = args.colour?.trim().toLowerCase() || (fit ? colours[0] : void 0);
1631
+ const wanted = (args.colour ? colourKey(args.colour) : "") || (fit ? colours[0] : void 0);
1615
1632
  if (wanted) {
1616
1633
  const resolved = imageFor(product, { fit, colour: wanted }) ?? (fit === null ? imageForColour(product, wanted) : null);
1617
1634
  if (resolved) {
1618
1635
  imageUrl = resolved;
1619
1636
  } else if (args.colour) {
1620
- blackNote = unavailable.includes(wanted) ? ` ${displayColour(wanted)} isn't available where you ship \u2014 showing the default mockup.` : ` ${displayColour(wanted)} available \u2014 showing the default mockup (no ${wanted} render on file).`;
1637
+ blackNote = unavailable.includes(wanted) ? ` ${displayColour(wanted)} isn't available where you ship \u2014 showing the default mockup.` : ` ${displayColour(wanted)} available \u2014 showing the default mockup (no ${displayColour(wanted)} render on file).`;
1621
1638
  }
1622
1639
  }
1623
1640
  if (imageUrl) {
@@ -1773,7 +1790,7 @@ async function runStage(client, config, args) {
1773
1790
  if (r.reason === "fit_unavailable") {
1774
1791
  return failResult({
1775
1792
  code: EXIT.DATAERR,
1776
- what: `${r.colour} is not available in ${r.fit} where you ship (${countryCode ?? "your region"}).`,
1793
+ what: `${colourLabel(r.colour ?? "")} is not available in ${r.fit} where you ship (${countryCode ?? "your region"}).`,
1777
1794
  money: "nothing staged, nothing charged.",
1778
1795
  fix: `bt view ${handleShown} --fit ${r.fit} (to see the colours you can buy)`
1779
1796
  });
@@ -1786,18 +1803,18 @@ async function runStage(client, config, args) {
1786
1803
  fix: r.sizes.length ? `bt stage ${handleShown} --fit ${r.fit} --size ${r.sizes[0]} (sizes here: ${r.sizes.join(" ")})` : `bt view ${handleShown} --fit ${r.fit} (to see the sizes you can buy)`
1787
1804
  });
1788
1805
  }
1789
- const have = r.colours.length ? ` available colours: ${r.colours.join(", ")}.` : "";
1806
+ const have = r.colours.length ? ` available colours: ${r.colours.map((c) => colourLabel(c)).join(", ")}.` : "";
1790
1807
  const haveSizes = r.sizes.length ? ` sizes: ${r.sizes.join(" ")}.` : "";
1791
1808
  return failResult({
1792
1809
  code: EXIT.DATAERR,
1793
- what: `no variant for ${args.handle}${r.fit ? ` --fit ${r.fit}` : ""}${size ? `#size=${size}` : ""}${r.colour ? ` (${r.colour})` : ""}.`,
1810
+ what: `no variant for ${args.handle}${r.fit ? ` --fit ${r.fit}` : ""}${size ? `#size=${size}` : ""}${r.colour ? ` (${colourLabel(r.colour)})` : ""}.`,
1794
1811
  fix: `bt view ${args.handle}${r.fit ? ` --fit ${r.fit}` : ""} (to see available sizes + colours)${have}${haveSizes}`
1795
1812
  });
1796
1813
  }
1797
1814
  const variant = r.variant;
1798
1815
  const colour = r.colour ?? void 0;
1799
1816
  const fit = r.fit;
1800
- const refTags = [colour, fit].filter(Boolean).join(", ");
1817
+ const refTags = [colour ? colourLabel(colour).toLowerCase() : null, fit].filter(Boolean).join(", ");
1801
1818
  const colourSuffix = refTags ? ` (${refTags})` : "";
1802
1819
  if (args.dryRun) {
1803
1820
  return {
@@ -1899,6 +1916,8 @@ export {
1899
1916
  coloursFor,
1900
1917
  sizesFor,
1901
1918
  priceFor,
1919
+ colourLabel,
1920
+ labelVariantTitle,
1902
1921
  productColours,
1903
1922
  findVariant,
1904
1923
  orderStage,
@@ -1943,4 +1962,4 @@ export {
1943
1962
  runStage,
1944
1963
  registerStage
1945
1964
  };
1946
- //# sourceMappingURL=chunk-CE324N5B.js.map
1965
+ //# sourceMappingURL=chunk-NMEL2CPI.js.map