@kianax/wt 0.1.3 → 0.1.4

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/dist/cli.js +78 -70
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -14851,7 +14851,7 @@ var package_default;
14851
14851
  var init_package = __esm(() => {
14852
14852
  package_default = {
14853
14853
  name: "@kianax/wt",
14854
- version: "0.1.3",
14854
+ version: "0.1.4",
14855
14855
  description: "Git worktree manager - make worktrees as effortless as branches",
14856
14856
  type: "module",
14857
14857
  main: "dist/cli.js",
@@ -53452,6 +53452,41 @@ var init_version = __esm(() => {
53452
53452
  VERSION2 = package_default.version;
53453
53453
  });
53454
53454
 
53455
+ // src/tui/components/columns.ts
53456
+ function formatRow(parts) {
53457
+ const { cursor, icon, name, path, age, status, suffix = "" } = parts;
53458
+ return [
53459
+ cursor.padEnd(COLUMNS.cursor),
53460
+ icon.padEnd(COLUMNS.icon),
53461
+ name.padEnd(COLUMNS.name),
53462
+ path.padEnd(COLUMNS.path),
53463
+ age.padEnd(COLUMNS.age),
53464
+ status.padEnd(COLUMNS.status),
53465
+ suffix
53466
+ ].join("");
53467
+ }
53468
+ function formatHeader() {
53469
+ return formatRow({
53470
+ cursor: "",
53471
+ icon: "",
53472
+ name: "name",
53473
+ path: "path",
53474
+ age: "age",
53475
+ status: "status"
53476
+ });
53477
+ }
53478
+ var COLUMNS;
53479
+ var init_columns = __esm(() => {
53480
+ COLUMNS = {
53481
+ cursor: 2,
53482
+ icon: 2,
53483
+ name: 20,
53484
+ path: 32,
53485
+ age: 4,
53486
+ status: 8
53487
+ };
53488
+ });
53489
+
53455
53490
  // src/tui/components/WorktreeItem.tsx
53456
53491
  function WorktreeItem({
53457
53492
  worktree,
@@ -53466,8 +53501,6 @@ function WorktreeItem({
53466
53501
  }
53467
53502
  }).catch(() => {});
53468
53503
  }, [worktree.path]);
53469
- const cursor = isSelected ? ">" : " ";
53470
- const icon = isCurrent ? "●" : "○";
53471
53504
  const path = contractHome(worktree.path);
53472
53505
  let statusBadge = "";
53473
53506
  let statusColor;
@@ -53493,79 +53526,61 @@ function WorktreeItem({
53493
53526
  statusBadge = "synced";
53494
53527
  statusColor = theme.status.synced;
53495
53528
  }
53496
- const maxPathLen = 32;
53497
- const displayPath = path.length > maxPathLen ? `...${path.slice(-(maxPathLen - 3))}` : path;
53498
- const { ahead, behind } = worktree;
53499
- const nameWidth = 20;
53529
+ const displayPath = path.length > COLUMNS.path ? `...${path.slice(-(COLUMNS.path - 3))}` : path;
53500
53530
  const primarySuffix = worktree.isPrimary ? " *" : "";
53501
- const maxNameLen = nameWidth - primarySuffix.length;
53502
- const truncatedName = worktree.name.slice(0, maxNameLen);
53503
- const namePadding = " ".repeat(nameWidth - truncatedName.length - primarySuffix.length);
53504
- const pathStr = displayPath.padEnd(32);
53505
- const ageStr = (age || "").padEnd(4);
53506
- const statusStr = statusBadge.padEnd(8);
53531
+ const maxNameLen = COLUMNS.name - primarySuffix.length;
53532
+ const displayName = worktree.name.slice(0, maxNameLen) + primarySuffix;
53533
+ const { ahead, behind } = worktree;
53534
+ let syncSuffix = "";
53535
+ if (ahead !== undefined && ahead > 0)
53536
+ syncSuffix += `+${ahead}`;
53537
+ if (behind !== undefined && behind > 0)
53538
+ syncSuffix += `-${behind}`;
53539
+ const rowText = formatRow({
53540
+ cursor: isSelected ? ">" : "",
53541
+ icon: isCurrent ? "*" : "",
53542
+ name: displayName,
53543
+ path: displayPath,
53544
+ age: age || "",
53545
+ status: statusBadge,
53546
+ suffix: syncSuffix
53547
+ });
53548
+ const cursorEnd = COLUMNS.cursor;
53549
+ const iconEnd = cursorEnd + COLUMNS.icon;
53550
+ const nameEnd = iconEnd + COLUMNS.name;
53551
+ const pathEnd = nameEnd + COLUMNS.path;
53552
+ const ageEnd = pathEnd + COLUMNS.age;
53553
+ const statusEnd = ageEnd + COLUMNS.status;
53507
53554
  return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
53508
53555
  children: [
53509
53556
  /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53510
53557
  color: isSelected ? theme.accent : undefined,
53511
- children: [
53512
- cursor,
53513
- " "
53514
- ]
53515
- }, undefined, true, undefined, this),
53558
+ children: rowText.slice(0, cursorEnd)
53559
+ }, undefined, false, undefined, this),
53516
53560
  /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53517
53561
  color: isCurrent ? theme.accent : "dim",
53518
- children: icon
53562
+ children: rowText.slice(cursorEnd, iconEnd)
53519
53563
  }, undefined, false, undefined, this),
53520
53564
  /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53521
53565
  color: isSelected ? theme.accent : undefined,
53522
- children: [
53523
- " ",
53524
- truncatedName
53525
- ]
53526
- }, undefined, true, undefined, this),
53527
- worktree.isPrimary && /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53528
- color: theme.status.primary,
53529
- children: primarySuffix
53530
- }, undefined, false, undefined, this),
53531
- /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53532
- children: namePadding
53566
+ children: rowText.slice(iconEnd, nameEnd)
53533
53567
  }, undefined, false, undefined, this),
53534
53568
  /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53535
53569
  dimColor: true,
53536
- children: [
53537
- " ",
53538
- pathStr
53539
- ]
53540
- }, undefined, true, undefined, this),
53570
+ children: rowText.slice(nameEnd, pathEnd)
53571
+ }, undefined, false, undefined, this),
53541
53572
  /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53542
53573
  dimColor: true,
53543
- children: [
53544
- " ",
53545
- ageStr
53546
- ]
53547
- }, undefined, true, undefined, this),
53574
+ children: rowText.slice(pathEnd, ageEnd)
53575
+ }, undefined, false, undefined, this),
53548
53576
  /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53549
53577
  color: statusColor,
53550
- children: [
53551
- " ",
53552
- statusStr
53553
- ]
53554
- }, undefined, true, undefined, this),
53555
- ahead !== undefined && ahead > 0 && /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53556
- color: theme.ui.success,
53557
- children: [
53558
- "↑",
53559
- ahead
53560
- ]
53561
- }, undefined, true, undefined, this),
53562
- behind !== undefined && behind > 0 && /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53563
- color: theme.status.behind,
53564
- children: [
53565
- "↓",
53566
- behind
53567
- ]
53568
- }, undefined, true, undefined, this)
53578
+ children: rowText.slice(ageEnd, statusEnd)
53579
+ }, undefined, false, undefined, this),
53580
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53581
+ color: ahead && ahead > 0 ? theme.ui.success : theme.status.behind,
53582
+ children: rowText.slice(statusEnd)
53583
+ }, undefined, false, undefined, this)
53569
53584
  ]
53570
53585
  }, undefined, true, undefined, this);
53571
53586
  }
@@ -53574,6 +53589,7 @@ var init_WorktreeItem = __esm(async () => {
53574
53589
  init_log();
53575
53590
  init_paths();
53576
53591
  init_theme();
53592
+ init_columns();
53577
53593
  await init_build2();
53578
53594
  import_react30 = __toESM(require_react(), 1);
53579
53595
  jsx_dev_runtime6 = __toESM(require_jsx_dev_runtime(), 1);
@@ -53640,17 +53656,8 @@ function WorktreeList({
53640
53656
  width: boxWidth - 2,
53641
53657
  children: /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
53642
53658
  dimColor: true,
53643
- children: [
53644
- " ",
53645
- "name".padEnd(20),
53646
- " ",
53647
- "path".padEnd(32),
53648
- " ",
53649
- "age".padEnd(4),
53650
- " ",
53651
- "status".padEnd(8)
53652
- ]
53653
- }, undefined, true, undefined, this)
53659
+ children: formatHeader()
53660
+ }, undefined, false, undefined, this)
53654
53661
  }, undefined, false, undefined, this),
53655
53662
  /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
53656
53663
  dimColor: true,
@@ -53692,6 +53699,7 @@ function WorktreeList({
53692
53699
  var jsx_dev_runtime7;
53693
53700
  var init_WorktreeList = __esm(async () => {
53694
53701
  init_version();
53702
+ init_columns();
53695
53703
  await __promiseAll([
53696
53704
  init_build2(),
53697
53705
  init_WorktreeItem()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kianax/wt",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Git worktree manager - make worktrees as effortless as branches",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",