@binaryandthread/cli 0.4.9 → 0.4.11
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 +3 -3
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-NMEL2CPI.js → chunk-UTSTDWKZ.js} +70 -23
- package/dist/chunk-UTSTDWKZ.js.map +1 -0
- package/dist/{interactive-4MFERLH7.js → interactive-UM5FCZDG.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-NMEL2CPI.js.map +0 -1
- /package/dist/{interactive-4MFERLH7.js.map → interactive-UM5FCZDG.js.map} +0 -0
|
@@ -624,12 +624,20 @@ 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", "coal", "eucalyptus", "bone"]
|
|
628
|
-
// TB124
|
|
627
|
+
"ascolour-5082": ["black", "white", "coal", "eucalyptus", "bone", "grey", "khaki", "indigo"],
|
|
628
|
+
// TB124, TB126
|
|
629
|
+
"bellacanvas-4711": ["asphalt", "dust", "navy", "maroon", "forest"]
|
|
630
|
+
// TB128: the sweatshirt
|
|
629
631
|
};
|
|
630
632
|
var PRINTFUL_BLANK_SIZES = {
|
|
631
|
-
"ascolour-5082": ["s", "m", "l", "xl", "2xl"]
|
|
633
|
+
"ascolour-5082": ["s", "m", "l", "xl", "2xl"],
|
|
634
|
+
"bellacanvas-4711": ["s", "m", "l", "xl", "2xl"]
|
|
632
635
|
};
|
|
636
|
+
function printfulBlankOf(p) {
|
|
637
|
+
const v = (p.metadata ?? {})["bt_blank"];
|
|
638
|
+
if (v === void 0 || v === null) return "ascolour-5082";
|
|
639
|
+
return typeof v === "string" && Object.prototype.hasOwnProperty.call(PRINTFUL_BLANK_COLOURS, v) ? v : null;
|
|
640
|
+
}
|
|
633
641
|
var PRINTFUL_SERVED_COUNTRIES = [
|
|
634
642
|
"se",
|
|
635
643
|
"us",
|
|
@@ -660,29 +668,30 @@ var PRINTFUL_SERVED_COUNTRIES = [
|
|
|
660
668
|
"si",
|
|
661
669
|
"es"
|
|
662
670
|
];
|
|
663
|
-
function printfulBlankFor(fit, countryCode) {
|
|
671
|
+
function printfulBlankFor(fit, countryCode, productBlank = "ascolour-5082") {
|
|
664
672
|
if (!PRINTFUL_SERVED_COUNTRIES.includes((countryCode ?? "").trim().toLowerCase())) return null;
|
|
665
|
-
|
|
673
|
+
if (productBlank === null) return null;
|
|
674
|
+
return fit === "regular" ? productBlank : null;
|
|
666
675
|
}
|
|
667
676
|
function sizeKey(size) {
|
|
668
677
|
const s = size.trim().toLowerCase();
|
|
669
678
|
return s === "xxl" ? "2xl" : s === "xxxl" ? "3xl" : s;
|
|
670
679
|
}
|
|
671
|
-
function blankRule(fit, countryCode, supplier) {
|
|
680
|
+
function blankRule(fit, countryCode, supplier, productBlank) {
|
|
672
681
|
if (supplier === null) return null;
|
|
673
682
|
if (supplier === "printful") {
|
|
674
|
-
const pb = printfulBlankFor(fit, countryCode);
|
|
683
|
+
const pb = printfulBlankFor(fit, countryCode, productBlank);
|
|
675
684
|
return pb ? { colours: PRINTFUL_BLANK_COLOURS[pb], sizes: PRINTFUL_BLANK_SIZES[pb] } : null;
|
|
676
685
|
}
|
|
677
686
|
const blank = blankFor(fit, countryCode);
|
|
678
687
|
return blank ? { colours: BLANK_COLOURS[blank], sizes: BLANK_SIZES[blank] } : null;
|
|
679
688
|
}
|
|
680
|
-
function colourBuyable(fit, colour, countryCode, supplier = "gelato") {
|
|
681
|
-
const rule2 = blankRule(fit, countryCode, supplier);
|
|
689
|
+
function colourBuyable(fit, colour, countryCode, supplier = "gelato", printfulBlank = "ascolour-5082") {
|
|
690
|
+
const rule2 = blankRule(fit, countryCode, supplier, printfulBlank);
|
|
682
691
|
return !!rule2 && rule2.colours.includes(colour.trim().toLowerCase());
|
|
683
692
|
}
|
|
684
|
-
function sizeBuyable(fit, size, countryCode, supplier = "gelato") {
|
|
685
|
-
const rule2 = blankRule(fit, countryCode, supplier);
|
|
693
|
+
function sizeBuyable(fit, size, countryCode, supplier = "gelato", printfulBlank = "ascolour-5082") {
|
|
694
|
+
const rule2 = blankRule(fit, countryCode, supplier, printfulBlank);
|
|
686
695
|
return !!rule2 && rule2.sizes.includes(sizeKey(size));
|
|
687
696
|
}
|
|
688
697
|
function legacyFit(p) {
|
|
@@ -701,11 +710,12 @@ function variantsOfFit(p, fit) {
|
|
|
701
710
|
function coloursFor(p, fit, countryCode) {
|
|
702
711
|
const gate = gateFit(p, fit);
|
|
703
712
|
const supplier = supplierOf(p);
|
|
713
|
+
const pb = printfulBlankOf(p);
|
|
704
714
|
const out = [];
|
|
705
715
|
for (const v of variantsOfFit(p, fit)) {
|
|
706
716
|
const c = variantColour(v);
|
|
707
717
|
if (!c || out.includes(c)) continue;
|
|
708
|
-
if (gate && countryCode !== void 0 && !colourBuyable(gate, c, countryCode, supplier)) continue;
|
|
718
|
+
if (gate && countryCode !== void 0 && !colourBuyable(gate, c, countryCode, supplier, pb)) continue;
|
|
709
719
|
out.push(c);
|
|
710
720
|
}
|
|
711
721
|
return out;
|
|
@@ -713,13 +723,14 @@ function coloursFor(p, fit, countryCode) {
|
|
|
713
723
|
function sizesFor(p, fit, colour, countryCode) {
|
|
714
724
|
const gate = gateFit(p, fit);
|
|
715
725
|
const supplier = supplierOf(p);
|
|
726
|
+
const pb = printfulBlankOf(p);
|
|
716
727
|
const target = colour.trim().toLowerCase();
|
|
717
728
|
const out = [];
|
|
718
729
|
for (const v of variantsOfFit(p, fit)) {
|
|
719
730
|
if (variantColour(v) !== target) continue;
|
|
720
731
|
const s = sizeOfVariant(v);
|
|
721
732
|
if (!s || out.includes(s)) continue;
|
|
722
|
-
if (gate && countryCode !== void 0 && !sizeBuyable(gate, s, countryCode, supplier)) continue;
|
|
733
|
+
if (gate && countryCode !== void 0 && !sizeBuyable(gate, s, countryCode, supplier, pb)) continue;
|
|
723
734
|
out.push(s);
|
|
724
735
|
}
|
|
725
736
|
return out;
|
|
@@ -758,21 +769,22 @@ function resolveVariant(p, opts) {
|
|
|
758
769
|
const pool = variantsOfFit(p, fit);
|
|
759
770
|
const gate = gateFit(p, fit);
|
|
760
771
|
const supplier = supplierOf(p);
|
|
772
|
+
const pb = printfulBlankOf(p);
|
|
761
773
|
const colours = coloursFor(p, fit, opts.countryCode);
|
|
762
774
|
const colour = colourKey(opts.colour ?? "") || (colours[0] ?? null);
|
|
763
|
-
if (gate && colour && opts.countryCode !== void 0 && !colourBuyable(gate, colour, opts.countryCode, supplier)) {
|
|
775
|
+
if (gate && colour && opts.countryCode !== void 0 && !colourBuyable(gate, colour, opts.countryCode, supplier, pb)) {
|
|
764
776
|
return { ok: false, reason: "fit_unavailable", fit: gate, colour };
|
|
765
777
|
}
|
|
766
778
|
const size = (opts.size ?? "").trim() || null;
|
|
767
779
|
const sizeLc = size?.toLowerCase();
|
|
768
780
|
const buyableSizes = colour ? sizesFor(p, fit, colour, opts.countryCode) : [];
|
|
769
781
|
const sizeExists = !!size && pool.some((x) => (sizeOfVariant(x) ?? x.title ?? "").toLowerCase() === size.toLowerCase());
|
|
770
|
-
if (gate && size && sizeExists && opts.countryCode !== void 0 && !sizeBuyable(gate, size, opts.countryCode, supplier)) {
|
|
782
|
+
if (gate && size && sizeExists && opts.countryCode !== void 0 && !sizeBuyable(gate, size, opts.countryCode, supplier, pb)) {
|
|
771
783
|
return { ok: false, reason: "size_unavailable", fit: gate, size, sizes: buyableSizes };
|
|
772
784
|
}
|
|
773
785
|
const sellable = gate && opts.countryCode !== void 0 ? pool.filter((x) => {
|
|
774
786
|
const s = sizeOfVariant(x);
|
|
775
|
-
return !s || sizeBuyable(gate, s, opts.countryCode, supplier);
|
|
787
|
+
return !s || sizeBuyable(gate, s, opts.countryCode, supplier, pb);
|
|
776
788
|
}) : pool;
|
|
777
789
|
const v = sellable.find((x) => {
|
|
778
790
|
const colourOk = !colour || variantColour(x) === colour;
|
|
@@ -789,7 +801,16 @@ var FIT_TOKEN = /^(regular|oversize)$/i;
|
|
|
789
801
|
function titleSegments(title) {
|
|
790
802
|
return (title ?? "").split("/").map((s) => s.trim()).filter(Boolean);
|
|
791
803
|
}
|
|
792
|
-
var COLOUR_LABELS = {
|
|
804
|
+
var COLOUR_LABELS = {
|
|
805
|
+
black: "Faded Black",
|
|
806
|
+
white: "Faded White",
|
|
807
|
+
coal: "Faded Coal",
|
|
808
|
+
eucalyptus: "Faded Eucalyptus",
|
|
809
|
+
bone: "Faded Bone",
|
|
810
|
+
grey: "Faded Grey",
|
|
811
|
+
khaki: "Faded Khaki",
|
|
812
|
+
indigo: "Faded Indigo"
|
|
813
|
+
};
|
|
793
814
|
function colourLabel(colour) {
|
|
794
815
|
const c = colour.trim();
|
|
795
816
|
if (!c) return c;
|
|
@@ -1610,7 +1631,7 @@ async function runView(client, config, args) {
|
|
|
1610
1631
|
lines.push(` colours ${colours.map((c) => `${colourSwatch(c)} ${colourLabel(c)}`).join(" \xB7 ")}`);
|
|
1611
1632
|
for (const c of colours) {
|
|
1612
1633
|
const sizes = sortSizes(sizesFor(product, fit, c, countryCode));
|
|
1613
|
-
lines.push(` ${colourSwatch(c)} ${colourLabel(c).padEnd(12)} ${sizes.join(" ")}`);
|
|
1634
|
+
lines.push(` ${colourSwatch(c)} ${colourLabel(c).padEnd(12)} ${sizes.join(" ").padEnd(22)} ${dim(style, `--colour ${c}`)}`);
|
|
1614
1635
|
}
|
|
1615
1636
|
for (const c of unavailable) {
|
|
1616
1637
|
lines.push(dim(style, ` ${colourSwatch(c)} ${colourLabel(c).padEnd(12)} not available where you ship (${countryCode ?? "your region"})`));
|
|
@@ -1644,6 +1665,13 @@ async function runView(client, config, args) {
|
|
|
1644
1665
|
if (blackNote) {
|
|
1645
1666
|
lines.push(blackNote);
|
|
1646
1667
|
}
|
|
1668
|
+
if (colours.length > 0) {
|
|
1669
|
+
const c0 = colours[0];
|
|
1670
|
+
const sz = sortSizes(sizesFor(product, fit, c0, countryCode));
|
|
1671
|
+
const pick = sz.find((s) => s.toUpperCase() === "M") ?? sz[0] ?? "M";
|
|
1672
|
+
const fitFlag = fit && fits.length > 1 ? ` --fit ${fit}` : "";
|
|
1673
|
+
lines.push(` stage one \u2192 bt stage ${handle}${fitFlag} --size ${pick} --colour ${c0} (colour is the one word shown on its row)`);
|
|
1674
|
+
}
|
|
1647
1675
|
if (colours.length > 1 && !args.colour) {
|
|
1648
1676
|
const others = colours.filter((c) => c !== colours[0]).join(", ");
|
|
1649
1677
|
lines.push(` see another colour \u2192 bt view ${handle} --colour ${others.split(",")[0]?.trim()}${fit && fits.length > 1 ? ` --fit ${fit}` : ""}`);
|
|
@@ -1787,6 +1815,17 @@ async function runStage(client, config, args) {
|
|
|
1787
1815
|
fix: r.fits.length ? `${r.fits.length > 1 ? "ask which fit is wanted, then: " : ""}${r.fits.map((f) => `bt stage ${handleShown} --fit ${f}${size ? ` --size ${size}` : ""}`).join(" | ")}` : `bt stage ${handleShown}${size ? ` --size ${size}` : ""} (this design comes in one fit)`
|
|
1788
1816
|
});
|
|
1789
1817
|
}
|
|
1818
|
+
const fitFlag = r.fit && productFits(product).length > 1 ? ` --fit ${r.fit}` : "";
|
|
1819
|
+
const colourAsked = "colour" in r ? r.colour : null;
|
|
1820
|
+
const madeIn = coloursFor(product, r.fit ?? null);
|
|
1821
|
+
if (colourAsked && (r.reason === "fit_unavailable" || r.reason === "not_found") && !madeIn.includes(colourAsked)) {
|
|
1822
|
+
return failResult({
|
|
1823
|
+
code: EXIT.DATAERR,
|
|
1824
|
+
what: `${handleShown} isn't made in ${colourAsked}. colours: ${madeIn.join(" \xB7 ")}.`,
|
|
1825
|
+
money: "nothing staged, nothing charged.",
|
|
1826
|
+
fix: madeIn.length ? `bt stage ${handleShown}${fitFlag}${size ? ` --size ${size}` : ""} --colour ${madeIn[0]} (one word, as listed)` : `bt view ${handleShown}`
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1790
1829
|
if (r.reason === "fit_unavailable") {
|
|
1791
1830
|
return failResult({
|
|
1792
1831
|
code: EXIT.DATAERR,
|
|
@@ -1803,12 +1842,20 @@ async function runStage(client, config, args) {
|
|
|
1803
1842
|
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)`
|
|
1804
1843
|
});
|
|
1805
1844
|
}
|
|
1806
|
-
const
|
|
1807
|
-
|
|
1845
|
+
const inColour = r.colour ? ` in ${r.colour}` : "";
|
|
1846
|
+
if (size && r.sizes.length) {
|
|
1847
|
+
return failResult({
|
|
1848
|
+
code: EXIT.DATAERR,
|
|
1849
|
+
what: `${handleShown} doesn't come in size ${size}${inColour}. sizes: ${r.sizes.join(" ")}.`,
|
|
1850
|
+
money: "nothing staged, nothing charged.",
|
|
1851
|
+
fix: `bt stage ${handleShown}${fitFlag} --size ${r.sizes[0]}${r.colour ? ` --colour ${r.colour}` : ""}`
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1808
1854
|
return failResult({
|
|
1809
1855
|
code: EXIT.DATAERR,
|
|
1810
|
-
what: `no variant for ${
|
|
1811
|
-
|
|
1856
|
+
what: `no variant for ${handleShown}${fitFlag}${size ? ` --size ${size}` : ""}${r.colour ? ` --colour ${r.colour}` : ""}.`,
|
|
1857
|
+
money: "nothing staged, nothing charged.",
|
|
1858
|
+
fix: `bt view ${handleShown}${fitFlag} (to see the sizes + colours you can buy)`
|
|
1812
1859
|
});
|
|
1813
1860
|
}
|
|
1814
1861
|
const variant = r.variant;
|
|
@@ -1962,4 +2009,4 @@ export {
|
|
|
1962
2009
|
runStage,
|
|
1963
2010
|
registerStage
|
|
1964
2011
|
};
|
|
1965
|
-
//# sourceMappingURL=chunk-
|
|
2012
|
+
//# sourceMappingURL=chunk-UTSTDWKZ.js.map
|