git-nav 0.0.1 → 0.0.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.
package/README.md CHANGED
@@ -6,3 +6,9 @@ Install Git Nav globally, then open the repository in the current directory:
6
6
  npm install --global git-nav
7
7
  git nav .
8
8
  ```
9
+
10
+ Serve the app over HTTP to reach it from another device on your network:
11
+
12
+ ```sh
13
+ git-nav serve --host 0.0.0.0
14
+ ```
package/bin/git-nav.js CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  import { spawn } from "node:child_process";
4
4
  import { createRequire } from "node:module";
5
- import { dirname, join } from "node:path";
5
+ import { dirname, join, normalize, relative, sep } from "node:path";
6
+ import { homedir } from "node:os";
7
+ import { realpathSync } from "node:fs";
6
8
  import { fileURLToPath } from "node:url";
7
9
 
8
10
  const require = createRequire(import.meta.url);
@@ -28,6 +30,56 @@ const packageRoot = join(dirname(fileURLToPath(import.meta.url)), "..");
28
30
  const { binaryScope } = require(join(packageRoot, "package.json"));
29
31
  const platformPackage = `${binaryScope}/${platformKey}`;
30
32
 
33
+ function updateCommandFor(packagePath) {
34
+ let resolvedPath;
35
+ try {
36
+ resolvedPath = realpathSync(packagePath);
37
+ } catch {
38
+ resolvedPath = normalize(packagePath);
39
+ }
40
+
41
+ const home = homedir();
42
+ const originalPath = normalize(packagePath);
43
+ const relativeToHome = relative(home, resolvedPath);
44
+ const originalRelativeToHome = relative(home, originalPath);
45
+ if (originalRelativeToHome.startsWith(`.npm${sep}_npx${sep}`)) {
46
+ return undefined;
47
+ }
48
+ if (relativeToHome.startsWith(`.bun${sep}install${sep}cache${sep}`)) {
49
+ return undefined;
50
+ }
51
+
52
+ const pathParts = resolvedPath.split(sep);
53
+ if (pathParts.at(-2) === "node_modules" && pathParts.at(-1) === "git-nav") {
54
+ const nodeModulesIndex = pathParts.length - 2;
55
+ if (pathParts[nodeModulesIndex - 1] === "lib") {
56
+ return "npm i -g git-nav@latest";
57
+ }
58
+ if (
59
+ originalRelativeToHome.includes(
60
+ `${sep}5${sep}node_modules${sep}git-nav`,
61
+ ) ||
62
+ pathParts.includes(".pnpm")
63
+ ) {
64
+ return "pnpm add -g git-nav@latest";
65
+ }
66
+ if (
67
+ relativeToHome ===
68
+ `.bun${sep}install${sep}global${sep}node_modules${sep}git-nav`
69
+ ) {
70
+ return "bun add -g git-nav@latest";
71
+ }
72
+ if (
73
+ relativeToHome ===
74
+ `.config${sep}yarn${sep}global${sep}node_modules${sep}git-nav`
75
+ ) {
76
+ return "yarn global add git-nav@latest";
77
+ }
78
+ }
79
+
80
+ return "npm i -g git-nav@latest";
81
+ }
82
+
31
83
  let executable;
32
84
  try {
33
85
  executable = require.resolve(`${platformPackage}/${binaryPath}`);
@@ -38,7 +90,13 @@ try {
38
90
  process.exit(1);
39
91
  }
40
92
 
41
- const child = spawn(executable, process.argv.slice(2), { stdio: "inherit" });
93
+ const updateCommand = updateCommandFor(packageRoot);
94
+ const child = spawn(executable, process.argv.slice(2), {
95
+ stdio: "inherit",
96
+ env: updateCommand
97
+ ? { ...process.env, GIT_NAV_UPDATE_COMMAND: updateCommand }
98
+ : process.env,
99
+ });
42
100
 
43
101
  child.on("error", (error) => {
44
102
  console.error(error.message);
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "git-nav",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "git-nav": "./bin/git-nav.js"
7
7
  },
8
8
  "binaryScope": "@git-nav",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/sangonz193/git-nav.git",
12
+ "directory": "packages/cli"
13
+ },
9
14
  "files": [
10
15
  "bin",
11
16
  "README.md"
@@ -17,12 +22,12 @@
17
22
  "node": ">=20"
18
23
  },
19
24
  "optionalDependencies": {
20
- "@git-nav/darwin-arm64": "0.0.1",
21
- "@git-nav/darwin-x64": "0.0.1",
22
- "@git-nav/linux-arm64": "0.0.1",
23
- "@git-nav/linux-x64": "0.0.1",
24
- "@git-nav/win32-arm64": "0.0.1",
25
- "@git-nav/win32-x64": "0.0.1"
25
+ "@git-nav/darwin-arm64": "0.0.3",
26
+ "@git-nav/darwin-x64": "0.0.3",
27
+ "@git-nav/linux-arm64": "0.0.3",
28
+ "@git-nav/linux-x64": "0.0.3",
29
+ "@git-nav/win32-arm64": "0.0.3",
30
+ "@git-nav/win32-x64": "0.0.3"
26
31
  },
27
32
  "scripts": {
28
33
  "build:package": "bun run --cwd ../../apps/desktop tauri build && bun scripts/package-platform.ts",