terminalmarket 0.11.1 → 0.11.2

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.
Files changed (2) hide show
  1. package/bin/tm.js +22 -9
  2. package/package.json +1 -1
package/bin/tm.js CHANGED
@@ -107,9 +107,15 @@ program
107
107
  .name("tm")
108
108
  .description("TerminalMarket CLI — marketplace for developers")
109
109
  .version(VERSION)
110
- .helpOption(false)
110
+ .helpOption('-h, --help', 'Show help')
111
111
  .addHelpCommand(false);
112
112
 
113
+ // Override --help to show our custom help instead of Commander's default
114
+ program.helpInformation = () => '';
115
+ program.on('--help', () => {
116
+ showHelp(null, 'basic');
117
+ });
118
+
113
119
  // -----------------
114
120
  // config
115
121
  // -----------------
@@ -459,14 +465,19 @@ cart
459
465
  try {
460
466
  const cartData = await apiGet("/cart");
461
467
 
468
+ // Normalize: API returns item.product.price, flatten for display
469
+ const items = (cartData.items || []).map((item) => ({
470
+ ...item,
471
+ name: item.name || item.product?.name || `Product #${item.productId}`,
472
+ price: item.price ?? item.product?.price ?? 0,
473
+ }));
474
+
462
475
  let total = 0;
463
- if (cartData.items?.length) {
464
- cartData.items.forEach((item) => {
465
- total += (item.price || 0) * (item.quantity || 1);
466
- });
467
- }
476
+ items.forEach((item) => {
477
+ total += (parseFloat(item.price) || 0) * (item.quantity || 1);
478
+ });
468
479
 
469
- printCart(cartData.items || [], total);
480
+ printCart(items, total);
470
481
  } catch (e) {
471
482
  printError(e?.message || String(e));
472
483
  process.exitCode = 1;
@@ -554,9 +565,11 @@ program
554
565
 
555
566
  let total = 0;
556
567
  cartData.items.forEach((item, i) => {
557
- const subtotal = (item.price || 0) * (item.quantity || 1);
568
+ const name = item.name || item.product?.name || `Product #${item.productId}`;
569
+ const price = parseFloat(item.price ?? item.product?.price ?? 0);
570
+ const subtotal = price * (item.quantity || 1);
558
571
  total += subtotal;
559
- console.log(` ${i + 1}. ${item.name} x${item.quantity} = $${subtotal.toFixed(2)}`);
572
+ console.log(` ${i + 1}. ${name} x${item.quantity} = $${subtotal.toFixed(2)}`);
560
573
  });
561
574
 
562
575
  console.log("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terminalmarket",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "TerminalMarket CLI — a curated marketplace for developers & founders (client for terminalmarket.app)",
5
5
  "bin": {
6
6
  "tm": "bin/tm.js"