@hanzo/dev 0.6.91 → 0.6.92

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.
@@ -2,90 +2,68 @@
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 "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";
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() !== "linux") return false;
12
+ if (platform() !== 'linux') return false;
13
13
  try {
14
- const rel = readFileSync("/proc/version", "utf8").toLowerCase();
15
- return rel.includes("microsoft") || !!process.env.WSL_DISTRO_NAME;
16
- } catch {
17
- return false;
18
- }
14
+ const rel = readFileSync('/proc/version', 'utf8').toLowerCase();
15
+ return rel.includes('microsoft') || !!process.env.WSL_DISTRO_NAME;
16
+ } catch { return false; }
19
17
  }
20
18
 
21
- const isWin = platform() === "win32";
19
+ const isWin = platform() === 'win32';
22
20
  const wsl = isWSL();
23
21
  const isWinLike = isWin || wsl;
24
22
 
25
23
  // Scope: only run for global installs, unless explicitly forced. Allow opt-out.
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";
24
+ const isGlobal = process.env.npm_config_global === 'true';
25
+ const force = process.env.CODE_FORCE_PREINSTALL === '1';
26
+ const skip = process.env.CODE_SKIP_PREINSTALL === '1';
29
27
  if (!isWinLike || skip || (!isGlobal && !force)) process.exit(0);
30
28
 
31
29
  function tryExec(cmd, opts = {}) {
32
- try {
33
- execSync(cmd, {
34
- stdio: ["ignore", "ignore", "ignore"],
35
- shell: true,
36
- ...opts,
37
- });
38
- } catch {
39
- /* ignore */
40
- }
30
+ try { execSync(cmd, { stdio: ['ignore', 'ignore', 'ignore'], shell: true, ...opts }); } catch { /* ignore */ }
41
31
  }
42
32
 
43
33
  // 1) Stop our native binary if it is holding locks. Avoid killing unrelated tools.
44
34
  // Only available on native Windows; skip entirely on WSL to avoid noise.
45
35
  if (isWin) {
46
- tryExec("taskkill /IM dev-x86_64-pc-windows-msvc.exe /F");
36
+ tryExec('taskkill /IM dev-x86_64-pc-windows-msvc.exe /F');
47
37
  }
48
38
 
49
39
  // 2) Remove stale staging dirs from previous failed installs under the global
50
40
  // @hanzo scope, which npm will reuse (e.g., .dev-XXXXX). Remove only
51
41
  // old entries and never the current staging or live package.
52
42
  try {
53
- let scopeDir = "";
43
+ let scopeDir = '';
54
44
  try {
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");
45
+ const root = execSync('npm root -g', { stdio: ['ignore', 'pipe', 'ignore'], shell: true }).toString().trim();
46
+ scopeDir = path.join(root, '@hanzo');
62
47
  } catch {
63
48
  // Fall back to guessing from this script location: <staging>\..\..\
64
49
  const here = path.resolve(path.dirname(fileURLToPath(import.meta.url)));
65
- scopeDir = path.resolve(here, "..");
50
+ scopeDir = path.resolve(here, '..');
66
51
  }
67
52
  if (existsSync(scopeDir)) {
68
53
  const now = Date.now();
69
54
  const maxAgeMs = 2 * 60 * 60 * 1000; // 2 hours
70
- const currentDir = path.resolve(
71
- path.dirname(fileURLToPath(import.meta.url)),
72
- "..",
73
- );
55
+ const currentDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
74
56
  for (const name of readdirSync(scopeDir)) {
75
- if (!name.startsWith(".dev-")) continue;
57
+ if (!name.startsWith('.dev-')) continue;
76
58
  const p = path.join(scopeDir, name);
77
59
  if (path.resolve(p) === currentDir) continue; // never remove our current dir
78
60
  try {
79
61
  const st = statSync(p);
80
62
  const age = now - st.mtimeMs;
81
63
  if (age > maxAgeMs) rmSync(p, { recursive: true, force: true });
82
- } catch {
83
- /* ignore */
84
- }
64
+ } catch { /* ignore */ }
85
65
  }
86
66
  }
87
- } catch {
88
- /* ignore */
89
- }
67
+ } catch { /* ignore */ }
90
68
 
91
69
  process.exit(0);
@@ -4,7 +4,7 @@ Closes running processes and removes stale package folders.
4
4
 
5
5
  Usage (PowerShell):
6
6
  Set-ExecutionPolicy -Scope Process Bypass -Force
7
- ./dev-cli/scripts/windows-cleanup.ps1
7
+ ./codex-cli/scripts/windows-cleanup.ps1
8
8
  #>
9
9
 
10
10
  $ErrorActionPreference = 'SilentlyContinue'
@@ -12,7 +12,6 @@ $ErrorActionPreference = 'SilentlyContinue'
12
12
  Write-Host "Stopping running Hanzo Dev processes..."
13
13
  taskkill /IM dev-x86_64-pc-windows-msvc.exe /F 2>$null | Out-Null
14
14
  taskkill /IM dev.exe /F 2>$null | Out-Null
15
- taskkill /IM hanzo.exe /F 2>$null | Out-Null
16
15
 
17
16
  Write-Host "Removing old global package (if present)..."
18
17
  $npmRoot = (& npm root -g).Trim()
@@ -29,3 +28,4 @@ Get-ChildItem -LiteralPath (Join-Path $npmRoot "@hanzo") -Force -ErrorAction Sil
29
28
  }
30
29
 
31
30
  Write-Host "Cleanup complete. You can now run: npm install -g @hanzo/dev@latest"
31
+