unity-hub-cli 0.3.0 → 0.4.0

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 +26 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,22 +6,26 @@ import { render } from "ink";
6
6
 
7
7
  // src/application/usecases.ts
8
8
  var ListProjectsUseCase = class {
9
- constructor(unityHubProjectsReader, gitRepositoryInfoReader, unityProjectOptionsReader) {
9
+ constructor(unityHubProjectsReader, gitRepositoryInfoReader, unityProjectOptionsReader, lockReader) {
10
10
  this.unityHubProjectsReader = unityHubProjectsReader;
11
11
  this.gitRepositoryInfoReader = gitRepositoryInfoReader;
12
12
  this.unityProjectOptionsReader = unityProjectOptionsReader;
13
+ this.lockReader = lockReader;
13
14
  }
14
15
  async execute() {
15
16
  const projects = await this.unityHubProjectsReader.listProjects();
16
- const repositoryInfoResults = await Promise.allSettled(
17
- projects.map((project) => this.gitRepositoryInfoReader.readRepositoryInfo(project.path))
18
- );
17
+ const [repositoryInfoResults, lockResults] = await Promise.all([
18
+ Promise.allSettled(
19
+ projects.map((project) => this.gitRepositoryInfoReader.readRepositoryInfo(project.path))
20
+ ),
21
+ Promise.allSettled(projects.map((project) => this.lockReader.isLocked(project.path)))
22
+ ]);
19
23
  return projects.map((project, index) => {
20
24
  const repositoryResult = repositoryInfoResults[index];
21
- if (repositoryResult.status === "fulfilled") {
22
- return { project, repository: repositoryResult.value ?? void 0 };
23
- }
24
- return { project };
25
+ const lockResult = lockResults[index];
26
+ const repository = repositoryResult.status === "fulfilled" ? repositoryResult.value ?? void 0 : void 0;
27
+ const isLocked = lockResult.status === "fulfilled" ? Boolean(lockResult.value) : false;
28
+ return { project, repository, isLocked };
25
29
  });
26
30
  }
27
31
  };
@@ -441,6 +445,12 @@ var UnityLockChecker = class {
441
445
  return "allow";
442
446
  }
443
447
  };
448
+ var UnityLockStatusReader = class {
449
+ async isLocked(projectPath) {
450
+ const lockfilePath = join3(projectPath, "Temp", "UnityLockfile");
451
+ return await pathExists(lockfilePath);
452
+ }
453
+ };
444
454
 
445
455
  // src/presentation/App.tsx
446
456
  import clipboard from "clipboardy";
@@ -534,6 +544,8 @@ var defaultHintMessage = "Move with arrows or j/k \xB7 Launch with o \xB7 Copy c
534
544
  var PROJECT_COLOR = "#abd8e7";
535
545
  var BRANCH_COLOR = "#e3839c";
536
546
  var PATH_COLOR = "#719bd8";
547
+ var LOCK_COLOR = "yellow";
548
+ var LOCK_LABEL = "[running]";
537
549
  var shortenHomePath = (targetPath) => {
538
550
  if (!homeDirectory) {
539
551
  return targetPath;
@@ -812,7 +824,7 @@ var App = ({
812
824
  });
813
825
  }, [linesPerProject, projects.length, startIndex, visibleProjects]);
814
826
  const rows = useMemo(() => {
815
- return visibleProjects.map(({ project, repository }, offset) => {
827
+ return visibleProjects.map(({ project, repository, isLocked }, offset) => {
816
828
  const rowIndex = startIndex + offset;
817
829
  const isSelected = rowIndex === index;
818
830
  const arrow = isSelected ? ">" : " ";
@@ -838,7 +850,8 @@ var App = ({
838
850
  " ",
839
851
  versionLabel
840
852
  ] }),
841
- updatedText ? /* @__PURE__ */ jsx(Text, { color: isSelected ? "green" : void 0, children: ` ${updatedText}` }) : null
853
+ updatedText ? /* @__PURE__ */ jsx(Text, { color: isSelected ? "green" : void 0, children: ` ${updatedText}` }) : null,
854
+ isLocked ? /* @__PURE__ */ jsx(Text, { color: LOCK_COLOR, children: ` ${LOCK_LABEL}` }) : null
842
855
  ] }),
843
856
  showBranch ? /* @__PURE__ */ jsxs(Text, { color: isSelected ? "green" : BRANCH_COLOR, children: [
844
857
  " ",
@@ -870,10 +883,12 @@ import { jsx as jsx2 } from "react/jsx-runtime";
870
883
  var bootstrap = async () => {
871
884
  const unityHubReader = new UnityHubProjectsReader();
872
885
  const gitRepositoryInfoReader = new GitRepositoryInfoReader();
886
+ const lockStatusReader = new UnityLockStatusReader();
873
887
  const listProjectsUseCase = new ListProjectsUseCase(
874
888
  unityHubReader,
875
889
  gitRepositoryInfoReader,
876
- unityHubReader
890
+ unityHubReader,
891
+ lockStatusReader
877
892
  );
878
893
  const editorPathResolver = new MacEditorPathResolver();
879
894
  const processLauncher = new NodeProcessLauncher();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unity-hub-cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
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": {