hookwright 1.2.2 → 1.2.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/README.md +2 -0
- package/dist/cli.js +34 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,6 +75,8 @@ Every command works without a TTY, for CI or scripting:
|
|
|
75
75
|
hookwright build --items 2 # cashfree-occ by default
|
|
76
76
|
hookwright build --provider razorpay-magic --items 2
|
|
77
77
|
hookwright build --provider nitro --event orders/create
|
|
78
|
+
hookwright build --provider nitro --event category_view --collection summer-sale
|
|
79
|
+
hookwright build --provider nitro --event view # no product needed
|
|
78
80
|
hookwright build --search "cold brew" # only products matching a title
|
|
79
81
|
hookwright build --items 3 --discount 250 --send
|
|
80
82
|
hookwright send --dry-run # print the request + curl, send nothing
|
package/dist/cli.js
CHANGED
|
@@ -24,7 +24,7 @@ var init_package = __esm({
|
|
|
24
24
|
"package.json"() {
|
|
25
25
|
package_default = {
|
|
26
26
|
name: "hookwright",
|
|
27
|
-
version: "1.2.
|
|
27
|
+
version: "1.2.3",
|
|
28
28
|
description: "Build real, signed e-commerce webhooks from a live Shopify catalogue \u2014 interactive terminal UI, no backend",
|
|
29
29
|
keywords: [
|
|
30
30
|
"webhook",
|
|
@@ -3536,18 +3536,42 @@ async function cmdBuild(args, config) {
|
|
|
3536
3536
|
const discount = Number.parseFloat(args.flags.discount ?? "0") || 0;
|
|
3537
3537
|
const search = typeof args.flags.search === "string" ? args.flags.search : void 0;
|
|
3538
3538
|
const checkImageUrls = args.flags.image !== false && args.flags["image-check"] !== false;
|
|
3539
|
-
|
|
3540
|
-
const
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3539
|
+
const provider = getProvider(providerId);
|
|
3540
|
+
const eventName = typeof args.flags.event === "string" ? args.flags.event : provider.defaultEvent;
|
|
3541
|
+
const selection = provider.selectionFor ? provider.selectionFor(eventName) : "cart";
|
|
3542
|
+
let items = [];
|
|
3543
|
+
let collection;
|
|
3544
|
+
if (selection === "collection") {
|
|
3545
|
+
log.step(`fetching collections from ${config.shopify.domain}\u2026`);
|
|
3546
|
+
const collections = await fetchCollections(config, { search });
|
|
3547
|
+
if (!collections.length) {
|
|
3548
|
+
log.fail("Shopify returned no collections");
|
|
3549
|
+
log.dim("create one in Shopify, or pick a different event");
|
|
3550
|
+
return 1;
|
|
3551
|
+
}
|
|
3552
|
+
const wanted = typeof args.flags.collection === "string" ? args.flags.collection.toLowerCase() : null;
|
|
3553
|
+
collection = collections.find((c2) => wanted && (c2.id === wanted || c2.handle === wanted || c2.title.toLowerCase() === wanted)) ?? collections[0];
|
|
3554
|
+
if (wanted && collection.title.toLowerCase() !== wanted && collection.id !== wanted && collection.handle !== wanted) {
|
|
3555
|
+
log.warn(`no collection matched "${args.flags.collection}", using ${collection.title}`);
|
|
3556
|
+
}
|
|
3557
|
+
log.ok(`collection: ${collection.title}`);
|
|
3558
|
+
} else if (selection !== "none") {
|
|
3559
|
+
log.step(`fetching products from ${config.shopify.domain}\u2026`);
|
|
3560
|
+
const products = await fetchCatalogue(config, { search });
|
|
3561
|
+
if (!products.length) {
|
|
3562
|
+
log.fail("Shopify returned no products");
|
|
3563
|
+
return 1;
|
|
3564
|
+
}
|
|
3565
|
+
items = autoSelect(products, selection === "product" ? 1 : count);
|
|
3566
|
+
log.ok(`${items.length} product(s): ${items.map((i) => i.product.title).join(", ")}`);
|
|
3567
|
+
} else {
|
|
3568
|
+
log.ok(`${eventName} needs no product or collection`);
|
|
3544
3569
|
}
|
|
3545
|
-
const items = autoSelect(products, count);
|
|
3546
|
-
log.ok(`${items.length} product(s): ${items.map((i) => i.product.title).join(", ")}`);
|
|
3547
3570
|
const built = await buildPayload4({
|
|
3548
3571
|
cfg: config,
|
|
3549
3572
|
providerId,
|
|
3550
|
-
eventName
|
|
3573
|
+
eventName,
|
|
3574
|
+
collection,
|
|
3551
3575
|
items,
|
|
3552
3576
|
discount,
|
|
3553
3577
|
phone: typeof args.flags.phone === "string" ? args.flags.phone : void 0,
|
|
@@ -3753,6 +3777,7 @@ ${c.bold("BUILD OPTIONS")}
|
|
|
3753
3777
|
--provider <id> cashfree-occ | razorpay-magic | nitro (default cashfree-occ)
|
|
3754
3778
|
--event <name> nitro only: view \xB7 category_view \xB7 product_view \xB7 addtocart
|
|
3755
3779
|
removefromcart \xB7 checkout \xB7 orders/create \xB7 orders/updated
|
|
3780
|
+
--collection <x> nitro category_view: collection id, handle or title
|
|
3756
3781
|
--items <n> how many products to put in the cart (default 1)
|
|
3757
3782
|
--search <text> only consider products matching a title
|
|
3758
3783
|
--discount <n> cart discount in major currency units (default 0)
|