@hanzo/dev 0.6.74 → 0.6.75
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/package.json +6 -6
- package/scripts/preinstall.js +45 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/dev",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.75",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Hanzo AI coding assistant - intelligent CLI for developers",
|
|
6
6
|
"bin": {
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"prettier": "^3.3.3"
|
|
36
36
|
},
|
|
37
37
|
"optionalDependencies": {
|
|
38
|
-
"@hanzo/dev-darwin-arm64": "0.6.
|
|
39
|
-
"@hanzo/dev-darwin-x64": "0.6.
|
|
40
|
-
"@hanzo/dev-linux-x64-musl": "0.6.
|
|
41
|
-
"@hanzo/dev-linux-arm64-musl": "0.6.
|
|
42
|
-
"@hanzo/dev-win32-x64": "0.6.
|
|
38
|
+
"@hanzo/dev-darwin-arm64": "0.6.75",
|
|
39
|
+
"@hanzo/dev-darwin-x64": "0.6.75",
|
|
40
|
+
"@hanzo/dev-linux-x64-musl": "0.6.75",
|
|
41
|
+
"@hanzo/dev-linux-arm64-musl": "0.6.75",
|
|
42
|
+
"@hanzo/dev-win32-x64": "0.6.75"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/scripts/preinstall.js
CHANGED
|
@@ -2,68 +2,90 @@
|
|
|
2
2
|
// Windows-friendly preinstall: proactively free file locks from prior installs
|
|
3
3
|
// so npm/yarn/pnpm can stage the new package. No-ops on non-Windows.
|
|
4
4
|
|
|
5
|
-
import { platform } from
|
|
6
|
-
import { execSync } from
|
|
7
|
-
import { existsSync, readdirSync, rmSync, readFileSync, statSync } from
|
|
8
|
-
import path from
|
|
9
|
-
import { fileURLToPath } from
|
|
5
|
+
import { platform } from "os";
|
|
6
|
+
import { execSync } from "child_process";
|
|
7
|
+
import { existsSync, readdirSync, rmSync, readFileSync, statSync } from "fs";
|
|
8
|
+
import path from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
10
|
|
|
11
11
|
function isWSL() {
|
|
12
|
-
if (platform() !==
|
|
12
|
+
if (platform() !== "linux") return false;
|
|
13
13
|
try {
|
|
14
|
-
const rel = readFileSync(
|
|
15
|
-
return rel.includes(
|
|
16
|
-
} catch {
|
|
14
|
+
const rel = readFileSync("/proc/version", "utf8").toLowerCase();
|
|
15
|
+
return rel.includes("microsoft") || !!process.env.WSL_DISTRO_NAME;
|
|
16
|
+
} catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
const isWin = platform() ===
|
|
21
|
+
const isWin = platform() === "win32";
|
|
20
22
|
const wsl = isWSL();
|
|
21
23
|
const isWinLike = isWin || wsl;
|
|
22
24
|
|
|
23
25
|
// Scope: only run for global installs, unless explicitly forced. Allow opt-out.
|
|
24
|
-
const isGlobal = process.env.npm_config_global ===
|
|
25
|
-
const force = process.env.DEV_FORCE_PREINSTALL ===
|
|
26
|
-
const skip = process.env.DEV_SKIP_PREINSTALL ===
|
|
26
|
+
const isGlobal = process.env.npm_config_global === "true";
|
|
27
|
+
const force = process.env.DEV_FORCE_PREINSTALL === "1";
|
|
28
|
+
const skip = process.env.DEV_SKIP_PREINSTALL === "1";
|
|
27
29
|
if (!isWinLike || skip || (!isGlobal && !force)) process.exit(0);
|
|
28
30
|
|
|
29
31
|
function tryExec(cmd, opts = {}) {
|
|
30
|
-
try {
|
|
32
|
+
try {
|
|
33
|
+
execSync(cmd, {
|
|
34
|
+
stdio: ["ignore", "ignore", "ignore"],
|
|
35
|
+
shell: true,
|
|
36
|
+
...opts,
|
|
37
|
+
});
|
|
38
|
+
} catch {
|
|
39
|
+
/* ignore */
|
|
40
|
+
}
|
|
31
41
|
}
|
|
32
42
|
|
|
33
43
|
// 1) Stop our native binary if it is holding locks. Avoid killing unrelated tools.
|
|
34
44
|
// Only available on native Windows; skip entirely on WSL to avoid noise.
|
|
35
45
|
if (isWin) {
|
|
36
|
-
tryExec(
|
|
46
|
+
tryExec("taskkill /IM dev-x86_64-pc-windows-msvc.exe /F");
|
|
37
47
|
}
|
|
38
48
|
|
|
39
49
|
// 2) Remove stale staging dirs from previous failed installs under the global
|
|
40
50
|
// @hanzo scope, which npm will reuse (e.g., .dev-XXXXX). Remove only
|
|
41
51
|
// old entries and never the current staging or live package.
|
|
42
52
|
try {
|
|
43
|
-
let scopeDir =
|
|
53
|
+
let scopeDir = "";
|
|
44
54
|
try {
|
|
45
|
-
const root = execSync(
|
|
46
|
-
|
|
55
|
+
const root = execSync("npm root -g", {
|
|
56
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
57
|
+
shell: true,
|
|
58
|
+
})
|
|
59
|
+
.toString()
|
|
60
|
+
.trim();
|
|
61
|
+
scopeDir = path.join(root, "@hanzo");
|
|
47
62
|
} catch {
|
|
48
63
|
// Fall back to guessing from this script location: <staging>\..\..\
|
|
49
64
|
const here = path.resolve(path.dirname(fileURLToPath(import.meta.url)));
|
|
50
|
-
scopeDir = path.resolve(here,
|
|
65
|
+
scopeDir = path.resolve(here, "..");
|
|
51
66
|
}
|
|
52
67
|
if (existsSync(scopeDir)) {
|
|
53
68
|
const now = Date.now();
|
|
54
69
|
const maxAgeMs = 2 * 60 * 60 * 1000; // 2 hours
|
|
55
|
-
const currentDir = path.resolve(
|
|
70
|
+
const currentDir = path.resolve(
|
|
71
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
72
|
+
"..",
|
|
73
|
+
);
|
|
56
74
|
for (const name of readdirSync(scopeDir)) {
|
|
57
|
-
if (!name.startsWith(
|
|
75
|
+
if (!name.startsWith(".dev-")) continue;
|
|
58
76
|
const p = path.join(scopeDir, name);
|
|
59
77
|
if (path.resolve(p) === currentDir) continue; // never remove our current dir
|
|
60
78
|
try {
|
|
61
79
|
const st = statSync(p);
|
|
62
80
|
const age = now - st.mtimeMs;
|
|
63
81
|
if (age > maxAgeMs) rmSync(p, { recursive: true, force: true });
|
|
64
|
-
} catch {
|
|
82
|
+
} catch {
|
|
83
|
+
/* ignore */
|
|
84
|
+
}
|
|
65
85
|
}
|
|
66
86
|
}
|
|
67
|
-
} catch {
|
|
87
|
+
} catch {
|
|
88
|
+
/* ignore */
|
|
89
|
+
}
|
|
68
90
|
|
|
69
91
|
process.exit(0);
|