git-nav 0.0.2 → 0.0.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.
- package/README.md +6 -0
- package/bin/git-nav.js +60 -2
- package/package.json +7 -7
package/README.md
CHANGED
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
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-nav",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"git-nav": "./bin/git-nav.js"
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
24
24
|
"optionalDependencies": {
|
|
25
|
-
"@git-nav/darwin-arm64": "0.0.
|
|
26
|
-
"@git-nav/darwin-x64": "0.0.
|
|
27
|
-
"@git-nav/linux-arm64": "0.0.
|
|
28
|
-
"@git-nav/linux-x64": "0.0.
|
|
29
|
-
"@git-nav/win32-arm64": "0.0.
|
|
30
|
-
"@git-nav/win32-x64": "0.0.
|
|
25
|
+
"@git-nav/darwin-arm64": "0.0.4",
|
|
26
|
+
"@git-nav/darwin-x64": "0.0.4",
|
|
27
|
+
"@git-nav/linux-arm64": "0.0.4",
|
|
28
|
+
"@git-nav/linux-x64": "0.0.4",
|
|
29
|
+
"@git-nav/win32-arm64": "0.0.4",
|
|
30
|
+
"@git-nav/win32-x64": "0.0.4"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build:package": "bun run --cwd ../../apps/desktop tauri build && bun scripts/package-platform.ts",
|