terminalmarket 0.7.2 → 0.7.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.
Files changed (2) hide show
  1. package/bin/tm.js +84 -48
  2. package/package.json +1 -1
package/bin/tm.js CHANGED
@@ -229,55 +229,87 @@ program
229
229
  // -----------------
230
230
  // profile command
231
231
  // -----------------
232
- program
232
+ const profile = program
233
233
  .command("profile")
234
- .description("View or edit your profile")
235
- .argument("[field]", "Field to set (name, phone, address, city, country)")
236
- .argument("[value...]", "Value to set")
234
+ .description("View or edit your profile");
235
+
236
+ async function showProfile() {
237
+ const result = await apiGet("/auth/status");
238
+ if (!result.isAuthenticated) {
239
+ console.log(chalk.yellow("Not logged in. Use 'tm login' first."));
240
+ return;
241
+ }
242
+ const user = result.user;
243
+ console.log();
244
+ console.log(chalk.green.bold('┌─────────────────────────────────────┐'));
245
+ console.log(chalk.green.bold('│') + chalk.white.bold(' Your Profile') + ' '.repeat(22) + chalk.green.bold('│'));
246
+ console.log(chalk.green.bold('└─────────────────────────────────────┘'));
247
+ console.log();
248
+ console.log(` ${chalk.dim('Username:')} ${chalk.white(user.username || user.email?.split('@')[0] || '-')}`);
249
+ console.log(` ${chalk.dim('Email:')} ${chalk.cyan(user.email || '-')}`);
250
+ console.log(` ${chalk.dim('Name:')} ${user.name || chalk.dim('(not set)')}`);
251
+ console.log(` ${chalk.dim('Phone:')} ${user.phone || chalk.dim('(not set)')}`);
252
+ console.log(` ${chalk.dim('Address:')} ${user.address || chalk.dim('(not set)')}`);
253
+ console.log(` ${chalk.dim('City:')} ${user.city || chalk.dim('(not set)')}`);
254
+ console.log(` ${chalk.dim('Country:')} ${user.country || chalk.dim('(not set)')}`);
255
+ console.log();
256
+ console.log(chalk.dim(' Use: tm profile set <field> <value>'));
257
+ console.log();
258
+ }
259
+
260
+ async function setProfileField(field, value) {
261
+ const result = await apiGet("/auth/status");
262
+ if (!result.isAuthenticated) {
263
+ console.log(chalk.yellow("Not logged in. Use 'tm login' first."));
264
+ return;
265
+ }
266
+ const validFields = ["name", "phone", "address", "city", "country"];
267
+ if (!validFields.includes(field)) {
268
+ console.error(chalk.red(`✗ Invalid field. Valid fields: ${validFields.join(", ")}`));
269
+ return;
270
+ }
271
+ const newValue = value.join(" ");
272
+ if (!newValue) {
273
+ console.error(chalk.red("✗ Value is required."));
274
+ return;
275
+ }
276
+ await apiPatch("/profile", { [field]: newValue });
277
+ console.log(chalk.green(`✓ Updated ${field} to "${newValue}"`));
278
+ }
279
+
280
+ profile
281
+ .command("view")
282
+ .description("Show your profile")
283
+ .action(async () => {
284
+ try {
285
+ await showProfile();
286
+ } catch (e) {
287
+ console.error(chalk.red(e?.message || String(e)));
288
+ process.exitCode = 1;
289
+ }
290
+ });
291
+
292
+ profile
293
+ .command("set <field> [value...]")
294
+ .description("Update profile field (name, phone, address, city, country)")
237
295
  .action(async (field, value) => {
238
296
  try {
239
- const result = await apiGet("/auth/status");
240
-
241
- if (!result.isAuthenticated) {
242
- console.log(chalk.yellow("Not logged in. Use 'tm login' first."));
243
- return;
244
- }
245
-
246
- if (!field) {
247
- const user = result.user;
248
- console.log(chalk.bold("Your Profile"));
249
- console.log("");
250
- console.log(`${chalk.dim("name:")} ${user.name || "(not set)"}`);
251
- console.log(`${chalk.dim("email:")} ${user.email}`);
252
- console.log(`${chalk.dim("phone:")} ${user.phone || "(not set)"}`);
253
- console.log(`${chalk.dim("address:")} ${user.address || "(not set)"}`);
254
- console.log(`${chalk.dim("city:")} ${user.city || "(not set)"}`);
255
- console.log(`${chalk.dim("country:")} ${user.country || "(not set)"}`);
256
- console.log("");
257
- console.log(chalk.dim("To update: tm profile <field> <value>"));
258
- return;
259
- }
260
-
261
- const validFields = ["name", "phone", "address", "city", "country"];
262
- if (!validFields.includes(field)) {
263
- console.error(chalk.red(`Invalid field. Valid fields: ${validFields.join(", ")}`));
264
- return;
265
- }
266
-
267
- const newValue = value.join(" ");
268
- if (!newValue) {
269
- console.error(chalk.red("Value is required."));
270
- return;
271
- }
272
-
273
- await apiPatch("/profile", { [field]: newValue });
274
- console.log(chalk.green(`Updated ${field} to "${newValue}"`));
297
+ await setProfileField(field, value);
275
298
  } catch (e) {
276
299
  console.error(chalk.red(e?.message || String(e)));
277
300
  process.exitCode = 1;
278
301
  }
279
302
  });
280
303
 
304
+ profile.action(async () => {
305
+ try {
306
+ await showProfile();
307
+ } catch (e) {
308
+ console.error(chalk.red(e?.message || String(e)));
309
+ process.exitCode = 1;
310
+ }
311
+ });
312
+
281
313
  // -----------------
282
314
  // cart commands
283
315
  // -----------------
@@ -1385,11 +1417,15 @@ program
1385
1417
  .command("about")
1386
1418
  .description("About TerminalMarket")
1387
1419
  .action(() => {
1420
+ const W = 40;
1421
+ const line = '═'.repeat(W);
1422
+ const pad = (s, w) => s + ' '.repeat(Math.max(0, w - s.length));
1423
+
1388
1424
  console.log();
1389
- console.log(chalk.green.bold(' ╔══════════════════════════════════════════════╗'));
1390
- console.log(chalk.green.bold(' ║') + chalk.white.bold(' TERMINAL MARKET') + chalk.green.bold(' ║'));
1391
- console.log(chalk.green.bold(' ║') + chalk.dim(' The marketplace for developers') + chalk.green.bold(' ║'));
1392
- console.log(chalk.green.bold(' ╚══════════════════════════════════════════════╝'));
1425
+ console.log(chalk.green.bold(' ' + line + '╗'));
1426
+ console.log(chalk.green.bold(' ║') + chalk.white.bold(pad(' TERMINAL MARKET', W)) + chalk.green.bold('║'));
1427
+ console.log(chalk.green.bold(' ║') + chalk.dim(pad(' The marketplace for developers', W)) + chalk.green.bold('║'));
1428
+ console.log(chalk.green.bold(' ' + line + '╝'));
1393
1429
  console.log();
1394
1430
  console.log(chalk.white(' We connect developers with premium services:'));
1395
1431
  console.log();
@@ -1404,7 +1440,7 @@ program
1404
1440
  console.log();
1405
1441
  console.log(` ${chalk.dim('Website:')} ${chalk.cyan('https://terminalmarket.app')}`);
1406
1442
  console.log(` ${chalk.dim('Install:')} ${chalk.green('npm i -g terminalmarket')}`);
1407
- console.log(` ${chalk.dim('Version:')} ${chalk.white('0.7.1')}`);
1443
+ console.log(` ${chalk.dim('Version:')} ${chalk.white('0.7.2')}`);
1408
1444
  console.log();
1409
1445
  });
1410
1446
 
@@ -1485,14 +1521,14 @@ function showHelp(commandName = null) {
1485
1521
  }
1486
1522
 
1487
1523
  // Show all commands grouped
1488
- const W = 35;
1524
+ const W = 38;
1489
1525
  const line = '═'.repeat(W);
1490
1526
  const pad = (s, w) => s + ' '.repeat(Math.max(0, w - s.length));
1491
1527
 
1492
1528
  console.log();
1493
1529
  console.log(chalk.green.bold(' ╔' + line + '╗'));
1494
- console.log(chalk.green.bold(' ║') + chalk.white.bold(pad(' TerminalMarket CLI ', W - 6)) + chalk.dim('v0.7.1') + chalk.green.bold('║'));
1495
- console.log(chalk.green.bold(' ║') + chalk.dim(pad(' Marketplace for developers', W)) + chalk.green.bold('║'));
1530
+ console.log(chalk.green.bold(' ║') + chalk.white.bold(pad(' TerminalMarket CLI', W - 8)) + chalk.dim(' v0.7.2 ') + chalk.green.bold('║'));
1531
+ console.log(chalk.green.bold(' ║') + chalk.dim(pad(' Marketplace for developers', W)) + chalk.green.bold('║'));
1496
1532
  console.log(chalk.green.bold(' ╚' + line + '╝'));
1497
1533
  console.log();
1498
1534
  console.log(chalk.magenta.bold('Usage:'), chalk.green('tm'), chalk.cyan('<command>'), chalk.dim('[options]'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terminalmarket",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "TerminalMarket CLI — marketplace for developers (client for terminalmarket.app)",
5
5
  "bin": {
6
6
  "tm": "./bin/tm.js"