browser4-cli 0.1.14 → 0.1.15

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser4-cli",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Browser automation CLI for AI agents",
5
5
  "type": "module",
6
6
  "files": [
@@ -67,9 +67,17 @@ $ErrorActionPreference = "Stop"
67
67
  # OS detection (compatible with PS 5.1+)
68
68
  # ──────────────────────────────────────────────
69
69
 
70
- $script:IsWin = [System.Environment]::OSVersion.Platform -eq "Win32NT"
71
- $script:IsMac = [System.Environment]::OSVersion.Platform -eq "Unix" -and (uname -s 2>$null) -eq "Darwin"
72
- $script:IsLinux = [System.Environment]::OSVersion.Platform -eq "Unix" -and (uname -s 2>$null) -ne "Darwin"
70
+ # Avoid assigning to $IsLinux / $IsWindows / $IsMacOS directly —
71
+ # they are read-only automatic variables in PowerShell 7+.
72
+ if ($PSVersionTable.PSVersion.Major -ge 6) {
73
+ $script:OSWin = $IsWindows
74
+ $script:OSLinux = $IsLinux
75
+ $script:OSMac = $IsMacOS
76
+ } else {
77
+ $script:OSWin = [System.Environment]::OSVersion.Platform -eq "Win32NT"
78
+ $script:OSMac = $false
79
+ $script:OSLinux = $false
80
+ }
73
81
 
74
82
  # ──────────────────────────────────────────────
75
83
  # Helpers
@@ -102,13 +110,13 @@ function Write-WarnMsg {
102
110
  function Get-PlatformKey {
103
111
  $arch = if ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq [System.Runtime.InteropServices.Architecture]::Arm64) { "arm64" } else { "x64" }
104
112
 
105
- if ($script:IsWin) {
113
+ if ($script:OSWin) {
106
114
  return "win32-$arch"
107
115
  }
108
- elseif ($script:IsMac) {
116
+ elseif ($script:OSMac) {
109
117
  return "darwin-$arch"
110
118
  }
111
- elseif ($script:IsLinux) {
119
+ elseif ($script:OSLinux) {
112
120
  # Detect musl
113
121
  $isMusl = $false
114
122
  try {
@@ -133,10 +141,10 @@ function Get-BinaryName {
133
141
  }
134
142
 
135
143
  function Get-DefaultInstallDir {
136
- if ($script:IsWin) {
144
+ if ($script:OSWin) {
137
145
  return Join-Path $env:LOCALAPPDATA "Programs\browser4-cli"
138
146
  }
139
- elseif ($script:IsLinux -or $script:IsMac) {
147
+ elseif ($script:OSLinux -or $script:OSMac) {
140
148
  # Prefer ~/.local/bin for user installs
141
149
  if (Test-Path "$env:HOME/.local/bin") {
142
150
  return "$env:HOME/.local/bin"
@@ -233,7 +241,7 @@ function New-PlatformLink {
233
241
  }
234
242
 
235
243
  # Try hard link (Windows, same volume)
236
- if ($script:IsWin) {
244
+ if ($script:OSWin) {
237
245
  try {
238
246
  $targetPath = Join-Path (Split-Path $LinkPath -Parent) $TargetName
239
247
  New-Item -ItemType HardLink -Path $LinkPath -Target $targetPath -Force -ErrorAction Stop | Out-Null
@@ -292,7 +300,7 @@ function New-Symlinks {
292
300
  }
293
301
 
294
302
  # Also check b4.cmd if on Windows (wrapper fallback)
295
- if ($script:IsWin) {
303
+ if ($script:OSWin) {
296
304
  $shortCmdPath = Join-Path $InstallDir "b4.cmd"
297
305
  if (Test-Path $shortCmdPath) {
298
306
  Write-WarnMsg "Skipping short link '$shortName': 'b4.cmd' already exists in $InstallDir"
@@ -415,7 +423,7 @@ Please check:
415
423
  }
416
424
 
417
425
  # On Unix, ensure executable bit
418
- if (-not $script:IsWin) {
426
+ if (-not $script:OSWin) {
419
427
  if (-not $DryRun) {
420
428
  try { chmod +x $binaryPath 2>$null } catch { }
421
429
  }
@@ -426,10 +434,10 @@ Please check:
426
434
  New-Symlinks -BinaryName $binaryName -InstallDir $installDir -PlatformKey $platformKey
427
435
 
428
436
  # Add to PATH
429
- if ($AddToPath -and $script:IsWin) {
437
+ if ($AddToPath -and $script:OSWin) {
430
438
  Write-Summary ""
431
439
  Add-DirectoryToUserPath -Dir $installDir
432
- } elseif ($AddToPath -and -not $script:IsWin) {
440
+ } elseif ($AddToPath -and -not $script:OSWin) {
433
441
  Write-Summary ""
434
442
  $shellRc = if (Test-Path "$env:HOME/.zshrc") { "$env:HOME/.zshrc" } elseif (Test-Path "$env:HOME/.bashrc") { "$env:HOME/.bashrc" } elseif (Test-Path "$env:HOME/.bash_profile") { "$env:HOME/.bash_profile" } else { "$env:HOME/.profile" }
435
443
  $pathLine = "export PATH=""$installDir`:`$PATH"""
@@ -465,7 +473,7 @@ Please check:
465
473
  Write-Summary ""
466
474
  Write-Summary "Run 'browser4-cli --help' to get started." -Color Cyan
467
475
 
468
- if ($script:IsWin) {
476
+ if ($script:OSWin) {
469
477
  Write-Summary "If the command isn't found, restart your terminal or run:"
470
478
  Write-Summary " `$env:Path = [System.Environment]::GetEnvironmentVariable('Path','User') + ';' + [System.Environment]::GetEnvironmentVariable('Path','Machine')"
471
479
  }