unity-hub-cli 0.13.0 → 0.13.1

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/index.js +43 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -959,6 +959,7 @@ var UnityTempDirectoryCleaner = class {
959
959
  };
960
960
 
961
961
  // src/presentation/App.tsx
962
+ import { basename as basename4 } from "path";
962
963
  import clipboard from "clipboardy";
963
964
  import { Box as Box6, Text as Text4, useApp, useInput, useStdout as useStdout2 } from "ink";
964
965
  import { useCallback, useEffect as useEffect4, useMemo as useMemo2, useState as useState4 } from "react";
@@ -1002,6 +1003,7 @@ var LayoutManager = ({
1002
1003
  };
1003
1004
 
1004
1005
  // src/presentation/components/ProjectList.tsx
1006
+ import { basename as basename3 } from "path";
1005
1007
  import { Box as Box3 } from "ink";
1006
1008
  import { useMemo } from "react";
1007
1009
 
@@ -1054,7 +1056,8 @@ var ProjectRow = ({
1054
1056
  pathLine,
1055
1057
  showBranch,
1056
1058
  showPath,
1057
- scrollbar
1059
+ scrollbar,
1060
+ showSpacer
1058
1061
  }) => {
1059
1062
  const { stdout } = useStdout();
1060
1063
  const computedCenterWidth = typeof stdout?.columns === "number" ? Math.max(0, stdout.columns - 6) : void 0;
@@ -1077,13 +1080,13 @@ var ProjectRow = ({
1077
1080
  ] }),
1078
1081
  showBranch ? /* @__PURE__ */ jsx2(Text, { color: "#e3839c", wrap: "truncate", children: branchLine }) : null,
1079
1082
  showPath ? /* @__PURE__ */ jsx2(Text, { color: "#719bd8", wrap: "truncate", children: pathLine }) : null,
1080
- /* @__PURE__ */ jsx2(Text, { children: " " })
1083
+ showSpacer ? /* @__PURE__ */ jsx2(Text, { children: " " }) : null
1081
1084
  ] }),
1082
1085
  /* @__PURE__ */ jsxs2(Box2, { marginLeft: 1, width: 1, flexDirection: "column", alignItems: "center", children: [
1083
1086
  /* @__PURE__ */ jsx2(Text, { children: scrollbar.title }),
1084
1087
  showBranch ? /* @__PURE__ */ jsx2(Text, { children: scrollbar.branch }) : null,
1085
1088
  showPath ? /* @__PURE__ */ jsx2(Text, { children: scrollbar.path }) : null,
1086
- /* @__PURE__ */ jsx2(Text, { children: scrollbar.spacer })
1089
+ showSpacer ? /* @__PURE__ */ jsx2(Text, { children: scrollbar.spacer }) : null
1087
1090
  ] })
1088
1091
  ] });
1089
1092
  };
@@ -1095,17 +1098,14 @@ var LOCK_COLOR = "yellow";
1095
1098
  var STATUS_LABELS = {
1096
1099
  idle: "",
1097
1100
  running: "[running]",
1098
- crashed: "[crash]"
1101
+ crashed: ""
1099
1102
  };
1100
1103
  var extractRootFolder = (repository) => {
1101
1104
  if (!repository?.root) {
1102
1105
  return void 0;
1103
1106
  }
1104
- const segments = repository.root.split("/").filter((segment) => segment.length > 0);
1105
- if (segments.length === 0) {
1106
- return void 0;
1107
- }
1108
- return segments[segments.length - 1];
1107
+ const base = basename3(repository.root);
1108
+ return base || void 0;
1109
1109
  };
1110
1110
  var formatProjectName = (projectTitle, repository, useGitRootName) => {
1111
1111
  if (!useGitRootName) {
@@ -1197,7 +1197,7 @@ var ProjectList = ({
1197
1197
  return [];
1198
1198
  }
1199
1199
  if (totalLines <= visibleLines) {
1200
- return Array.from({ length: visibleLines }, () => "\u2588");
1200
+ return Array.from({ length: visibleLines }, () => " ");
1201
1201
  }
1202
1202
  const trackLength = visibleLines;
1203
1203
  const sliderSize = Math.max(1, Math.round(visibleLines / totalLines * trackLength));
@@ -1242,7 +1242,7 @@ var ProjectList = ({
1242
1242
  const pathScrollbar = showPath ? scrollbarChars[baseScrollbarIndex + 1 + (showBranch ? 1 : 0)] ?? " " : " ";
1243
1243
  const spacerScrollbar = scrollbarChars[baseScrollbarIndex + linesPerProject - 1] ?? " ";
1244
1244
  const statusLabel = STATUS_LABELS[displayStatus];
1245
- const statusColor = displayStatus === "running" ? LOCK_COLOR : displayStatus === "crashed" ? "red" : void 0;
1245
+ const statusColor = displayStatus === "running" ? LOCK_COLOR : void 0;
1246
1246
  return /* @__PURE__ */ jsx3(
1247
1247
  ProjectRow,
1248
1248
  {
@@ -1263,7 +1263,8 @@ var ProjectList = ({
1263
1263
  branch: branchScrollbar,
1264
1264
  path: pathScrollbar,
1265
1265
  spacer: spacerScrollbar
1266
- }
1266
+ },
1267
+ showSpacer: offset < visibleProjects.length - 1
1267
1268
  },
1268
1269
  project.id
1269
1270
  );
@@ -1502,14 +1503,14 @@ var useVisibilityPreferences = () => {
1502
1503
 
1503
1504
  // src/presentation/hooks/useVisibleCount.ts
1504
1505
  import { useEffect as useEffect3, useState as useState3 } from "react";
1505
- var useVisibleCount = (stdout, linesPerProject, panelVisible, panelHeight, minimumVisibleProjectCount2) => {
1506
+ var useVisibleCount = (stdout, linesPerProject, panelVisible, panelHeight, minimumVisibleProjectCount2, statusBarRows) => {
1506
1507
  const compute = () => {
1507
1508
  if (!stdout || typeof stdout.columns !== "number" || typeof stdout.rows !== "number") {
1508
1509
  return minimumVisibleProjectCount2;
1509
1510
  }
1510
1511
  const borderRows = 2;
1511
- const hintRows = 1;
1512
- const reservedRows = borderRows + hintRows + (panelVisible ? panelHeight : 0);
1512
+ const hintRows = Math.max(1, statusBarRows);
1513
+ const reservedRows = borderRows + hintRows + (panelVisible ? panelHeight + 1 : 0);
1513
1514
  const availableRows = Math.max(0, stdout.rows - reservedRows);
1514
1515
  const rowsPerProject = Math.max(linesPerProject, 1);
1515
1516
  const calculatedCount = Math.max(1, Math.floor(availableRows / rowsPerProject));
@@ -1523,7 +1524,7 @@ var useVisibleCount = (stdout, linesPerProject, panelVisible, panelHeight, minim
1523
1524
  return () => {
1524
1525
  stdout?.off("resize", updateVisible);
1525
1526
  };
1526
- }, [stdout, linesPerProject, panelVisible, panelHeight]);
1527
+ }, [stdout, linesPerProject, panelVisible, panelHeight, statusBarRows]);
1527
1528
  return visibleCount;
1528
1529
  };
1529
1530
 
@@ -1533,14 +1534,11 @@ var extractRootFolder2 = (repository) => {
1533
1534
  if (!repository?.root) {
1534
1535
  return void 0;
1535
1536
  }
1536
- const segments = repository.root.split("/").filter((segment) => segment.length > 0);
1537
- if (segments.length === 0) {
1538
- return void 0;
1539
- }
1540
- return segments[segments.length - 1];
1537
+ const base = basename4(repository.root);
1538
+ return base || void 0;
1541
1539
  };
1542
1540
  var minimumVisibleProjectCount = 4;
1543
- var defaultHintMessage = "Select: j/k \xB7 Open: o \xB7 Quit: q \xB7 Refresh: r \xB7 CopyPath: c \xB7 Sort: s \xB7 Visibility: v \xB7 Close: ctrl + c";
1541
+ var defaultHintMessage = "j/k Select \xB7 [o]pen [q]uit [r]efresh [c]opy [s]ort [v]isibility \xB7 ^C Exit";
1544
1542
  var getCopyTargetPath = (view) => {
1545
1543
  const root = view.repository?.root;
1546
1544
  return root && root.length > 0 ? root : view.project.path;
@@ -1565,7 +1563,6 @@ var App = ({
1565
1563
  const linesPerProject = (showBranch ? 1 : 0) + (showPath ? 1 : 0) + 2;
1566
1564
  const isAnyMenuOpen = isSortMenuOpen || isVisibilityMenuOpen;
1567
1565
  const panelHeight = isVisibilityMenuOpen ? visibilityPanelHeight : sortPanelHeight;
1568
- const visibleCount = useVisibleCount(stdout, linesPerProject, isAnyMenuOpen, panelHeight, minimumVisibleProjectCount);
1569
1566
  const [index, setIndex] = useState4(0);
1570
1567
  const [hint, setHint] = useState4(defaultHintMessage);
1571
1568
  const [windowStart, setWindowStart] = useState4(0);
@@ -1573,7 +1570,18 @@ var App = ({
1573
1570
  const [launchedProjects, setLaunchedProjects] = useState4(/* @__PURE__ */ new Set());
1574
1571
  const [isRefreshing, setIsRefreshing] = useState4(false);
1575
1572
  const [sortMenuIndex, setSortMenuIndex] = useState4(0);
1573
+ const [directionManuallyChanged, setDirectionManuallyChanged] = useState4(false);
1576
1574
  const { sortPreferences, setSortPreferences } = useSortPreferences();
1575
+ const columns = typeof stdout?.columns === "number" ? stdout.columns : void 0;
1576
+ const statusBarRows = isAnyMenuOpen ? 1 : Math.max(1, typeof columns === "number" && columns > 0 ? Math.ceil(hint.length / columns) : 1);
1577
+ const visibleCount = useVisibleCount(
1578
+ stdout,
1579
+ linesPerProject,
1580
+ isAnyMenuOpen,
1581
+ panelHeight,
1582
+ minimumVisibleProjectCount,
1583
+ statusBarRows
1584
+ );
1577
1585
  const clearScreen = useCallback(() => {
1578
1586
  stdout?.write("\x1B[2J\x1B[3J\x1B[H");
1579
1587
  }, [stdout]);
@@ -1908,10 +1916,15 @@ var App = ({
1908
1916
  }
1909
1917
  const toggleCurrent = () => {
1910
1918
  if (sortMenuIndex === 0) {
1911
- setSortPreferences((prev) => ({ ...prev, primary: prev.primary === "updated" ? "name" : "updated" }));
1919
+ setSortPreferences((prev) => {
1920
+ const nextPrimary = prev.primary === "updated" ? "name" : "updated";
1921
+ const nextDirection = nextPrimary === "name" && !directionManuallyChanged ? "asc" : prev.direction;
1922
+ return { ...prev, primary: nextPrimary, direction: nextDirection };
1923
+ });
1912
1924
  return;
1913
1925
  }
1914
1926
  if (sortMenuIndex === 1) {
1927
+ setDirectionManuallyChanged(true);
1915
1928
  setSortPreferences((prev) => ({ ...prev, direction: prev.direction === "asc" ? "desc" : "asc" }));
1916
1929
  return;
1917
1930
  }
@@ -2060,7 +2073,7 @@ var App = ({
2060
2073
  ) })
2061
2074
  ] })
2062
2075
  ] }),
2063
- statusBar: isAnyMenuOpen ? /* @__PURE__ */ jsx6(Text4, { wrap: "truncate", children: "Select: j/k, Toggle: Space, Back: Esc" }) : /* @__PURE__ */ jsx6(Text4, { wrap: "truncate", children: hint })
2076
+ statusBar: isAnyMenuOpen ? /* @__PURE__ */ jsx6(Text4, { wrap: "truncate", children: "Select: j/k, Toggle: Space, Back: Esc" }) : /* @__PURE__ */ jsx6(Text4, { wrap: "wrap", children: hint })
2064
2077
  }
2065
2078
  );
2066
2079
  };
@@ -2137,4 +2150,8 @@ var bootstrap = async () => {
2137
2150
  process2.exitCode = 1;
2138
2151
  }
2139
2152
  };
2140
- await bootstrap();
2153
+ void bootstrap().catch((error) => {
2154
+ const message = error instanceof Error ? error.message : String(error);
2155
+ console.error(message);
2156
+ process2.exitCode = 1;
2157
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unity-hub-cli",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "A CLI tool that reads Unity Hub's projects and launches Unity Editor with an interactive TUI",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {