squeezr-ai 1.16.12 → 1.16.13
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/bin/squeezr.js +52 -1
- package/package.json +1 -1
package/bin/squeezr.js
CHANGED
|
@@ -531,7 +531,22 @@ async function uninstall() {
|
|
|
531
531
|
const tomlPath = path.join(ROOT, 'squeezr.toml')
|
|
532
532
|
try { fs.unlinkSync(tomlPath) } catch {}
|
|
533
533
|
|
|
534
|
-
// 7.
|
|
534
|
+
// 7. Remove PowerShell wrapper function from profile
|
|
535
|
+
if (process.platform === 'win32') {
|
|
536
|
+
try {
|
|
537
|
+
const psProfilePath = execSync('powershell -NoProfile -Command "[Environment]::GetFolderPath(\'MyDocuments\') + \'\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1\'"', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim()
|
|
538
|
+
if (fs.existsSync(psProfilePath)) {
|
|
539
|
+
const content = fs.readFileSync(psProfilePath, 'utf-8')
|
|
540
|
+
if (content.includes('# squeezr wrapper')) {
|
|
541
|
+
const cleaned = content.replace(/\n?# squeezr wrapper[\s\S]*?# end squeezr wrapper\n?/g, '')
|
|
542
|
+
fs.writeFileSync(psProfilePath, cleaned)
|
|
543
|
+
console.log(` [ok] Removed PowerShell wrapper from ${psProfilePath}`)
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
} catch {}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// 8. npm uninstall -g (clear HTTPS_PROXY first so npm doesn't hit dead proxy)
|
|
535
550
|
console.log(' [..] Uninstalling npm package...')
|
|
536
551
|
const cleanEnv = { ...process.env, HTTPS_PROXY: '', https_proxy: '', HTTP_PROXY: '', http_proxy: '' }
|
|
537
552
|
try {
|
|
@@ -581,6 +596,42 @@ function setupWindows() {
|
|
|
581
596
|
}
|
|
582
597
|
}
|
|
583
598
|
|
|
599
|
+
// 1b. Install PowerShell wrapper function so env vars are refreshed automatically
|
|
600
|
+
// after squeezr start/setup/update (child processes can't modify parent env).
|
|
601
|
+
try {
|
|
602
|
+
const psProfilePath = execSync('powershell -NoProfile -Command "[Environment]::GetFolderPath(\'MyDocuments\') + \'\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1\'"', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim()
|
|
603
|
+
const psProfileDir = path.dirname(psProfilePath)
|
|
604
|
+
if (!fs.existsSync(psProfileDir)) fs.mkdirSync(psProfileDir, { recursive: true })
|
|
605
|
+
const psMarker = '# squeezr wrapper'
|
|
606
|
+
const psFunction = `${psMarker}
|
|
607
|
+
function squeezr {
|
|
608
|
+
$bin = (Get-Command squeezr.cmd -ErrorAction SilentlyContinue).Source
|
|
609
|
+
if (-not $bin) { $bin = (Get-Command squeezr -ErrorAction SilentlyContinue).Source }
|
|
610
|
+
& node $bin @args
|
|
611
|
+
if ($args[0] -match '^(start|setup|update)$') {
|
|
612
|
+
@('ANTHROPIC_BASE_URL','GEMINI_API_BASE_URL','HTTPS_PROXY','NODE_EXTRA_CA_CERTS') | ForEach-Object {
|
|
613
|
+
$v = [Environment]::GetEnvironmentVariable($_, 'User')
|
|
614
|
+
if ($v) { [Environment]::SetEnvironmentVariable($_, $v, 'Process') }
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
if ($args[0] -eq 'stop') {
|
|
618
|
+
[Environment]::SetEnvironmentVariable('HTTPS_PROXY', $null, 'Process')
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
# end squeezr wrapper`
|
|
622
|
+
const existing = fs.existsSync(psProfilePath) ? fs.readFileSync(psProfilePath, 'utf-8') : ''
|
|
623
|
+
if (!existing.includes(psMarker)) {
|
|
624
|
+
fs.appendFileSync(psProfilePath, `\n${psFunction}\n`)
|
|
625
|
+
console.log(` [ok] PowerShell wrapper added to ${psProfilePath}`)
|
|
626
|
+
} else {
|
|
627
|
+
const updated = existing.replace(/# squeezr wrapper[\s\S]*?# end squeezr wrapper/, psFunction)
|
|
628
|
+
fs.writeFileSync(psProfilePath, updated)
|
|
629
|
+
console.log(` [ok] PowerShell wrapper updated in ${psProfilePath}`)
|
|
630
|
+
}
|
|
631
|
+
} catch (err) {
|
|
632
|
+
console.log(` [skip] PowerShell profile wrapper could not be installed`)
|
|
633
|
+
}
|
|
634
|
+
|
|
584
635
|
// 2. Auto-start: try NSSM (Windows service, survives crashes) → fallback to Task Scheduler
|
|
585
636
|
const logDir = path.join(os.homedir(), '.squeezr')
|
|
586
637
|
const serviceName = 'SqueezrProxy'
|
package/package.json
CHANGED