@@ -10,44 +10,6 @@ import { install_bun } from './bun'
10
10
import { config } from './config'
11
11
import { Path } from './path'
12
12
13
- /**
14
- * Execute a command with optional sudo support
15
- */
16
- function execWithSudo ( command : string , options : any = { } , useSudo = false ) : Buffer | string {
17
- if ( useSudo && process . platform !== 'win32' ) {
18
- const sudoPassword = process . env . SUDO_PASSWORD
19
- if ( sudoPassword ) {
20
- // Use echo and pipe for non-interactive sudo
21
- const sudoCommand = `echo "${ sudoPassword } " | sudo -S ${ command } `
22
- return execSync ( sudoCommand , options )
23
- }
24
- else {
25
- // Fallback to regular sudo (might prompt)
26
- return execSync ( `sudo ${ command } ` , options )
27
- }
28
- }
29
- return execSync ( command , options )
30
- }
31
-
32
- /**
33
- * Check if we need sudo for writing to a directory
34
- */
35
- function needsSudo ( targetPath : string ) : boolean {
36
- if ( process . platform === 'win32' )
37
- return false
38
-
39
- try {
40
- // Check if we can write to the target directory
41
- const testDir = path . dirname ( targetPath )
42
- fs . accessSync ( testDir , fs . constants . W_OK )
43
- return false
44
- }
45
- catch {
46
- // If we can't write, we might need sudo
47
- return targetPath . startsWith ( '/usr/' ) || targetPath . startsWith ( '/opt/' ) || targetPath . startsWith ( '/Library/' )
48
- }
49
- }
50
-
51
13
// Global message deduplication for shell mode
52
14
const shellModeMessageCache = new Set < string > ( )
53
15
let hasTemporaryProcessingMessage = false
@@ -2232,7 +2194,8 @@ export async function downloadPackage(
2232
2194
if ( config . verbose ) {
2233
2195
logUniqueMessage ( `ℹ️ ${ domain } installed (certificate bundle, no binaries expected)` )
2234
2196
}
2235
- } else {
2197
+ }
2198
+ else {
2236
2199
logUniqueMessage ( `⚠️ Package ${ domain } appears incomplete, source build not available...` )
2237
2200
}
2238
2201
}
@@ -2938,7 +2901,7 @@ async function installPackage(packageName: string, packageSpec: string, installP
2938
2901
let actualPackageSpec = packageSpec
2939
2902
const osMatch = packageSpec . match ( / ^ ( d a r w i n | l i n u x | w i n d o w s | f r e e b s d | o p e n b s d | n e t b s d ) @ ( [ ^ : ] + ) ( : .* ) ? $ / )
2940
2903
if ( osMatch ) {
2941
- const [ , osPrefix , basePkg , versionConstraint ] = osMatch
2904
+ const [ , _osPrefix , basePkg , versionConstraint ] = osMatch
2942
2905
// Fix malformed version constraints: ": ^1" -> "@^1"
2943
2906
if ( versionConstraint ) {
2944
2907
const cleanVersion = versionConstraint . replace ( / ^ : \s * / , '@' )
@@ -4198,7 +4161,7 @@ export async function installDependenciesOnly(packages: string[], installPath?:
4198
4161
// Fallback to partial matches only if no exact match found
4199
4162
if ( ! packageKey ) {
4200
4163
packageKey = Object . keys ( pantry ) . find ( key =>
4201
- key . includes ( packageName ) || key . includes ( domain . split ( '.' ) [ 0 ] )
4164
+ key . includes ( packageName ) || key . includes ( domain . split ( '.' ) [ 0 ] ) ,
4202
4165
)
4203
4166
}
4204
4167
@@ -4232,9 +4195,9 @@ export async function installDependenciesOnly(packages: string[], installPath?:
4232
4195
const depDomain = dep . split ( / [ < > = ~ ^ ] / ) [ 0 ]
4233
4196
4234
4197
// Skip if this dependency is the same as the main package we're installing deps for
4235
- if ( depDomain === domain || depDomain === packageName ||
4236
- ( packageName === 'php' && depDomain === 'php.net' ) ||
4237
- ( domain === 'php.net' && depDomain === 'php.net' ) ) {
4198
+ if ( depDomain === domain || depDomain === packageName
4199
+ || ( packageName === 'php' && depDomain === 'php.net' )
4200
+ || ( domain === 'php.net' && depDomain === 'php.net' ) ) {
4238
4201
if ( config . verbose ) {
4239
4202
console . log ( `⏭️ Skipping ${ dep } (this is the main package, not a dependency)` )
4240
4203
}
@@ -4252,7 +4215,7 @@ export async function installDependenciesOnly(packages: string[], installPath?:
4252
4215
return ! alreadyInstalled
4253
4216
} )
4254
4217
4255
- totalDepsProcessed += filteredDeps . length
4218
+ // totalDepsProcessed += filteredDeps.length
4256
4219
4257
4220
if ( depsToInstall . length === 0 ) {
4258
4221
if ( config . verbose ) {
@@ -4274,8 +4237,8 @@ export async function installDependenciesOnly(packages: string[], installPath?:
4274
4237
if ( config . verbose ) {
4275
4238
console . log ( `✅ Successfully installed ${ depsToInstall . length } dependencies for ${ packageName } ` )
4276
4239
}
4277
- }
4278
- catch ( error ) {
4240
+ }
4241
+ catch {
4279
4242
console . warn ( `⚠️ Some dependencies for ${ packageName } failed to install, trying individual installation` )
4280
4243
4281
4244
// Fallback to individual installation
@@ -4297,9 +4260,11 @@ export async function installDependenciesOnly(packages: string[], installPath?:
4297
4260
// Improved final message
4298
4261
if ( allInstalledFiles . length > 0 ) {
4299
4262
console . log ( `🎉 Dependencies installation complete. Installed ${ allInstalledFiles . length } files for ${ packages . join ( ', ' ) } .` )
4300
- } else if ( totalDepsAlreadyInstalled > 0 ) {
4263
+ }
4264
+ else if ( totalDepsAlreadyInstalled > 0 ) {
4301
4265
console . log ( `✅ All ${ totalDepsAlreadyInstalled } dependencies for ${ packages . join ( ', ' ) } were already installed.` )
4302
- } else {
4266
+ }
4267
+ else {
4303
4268
console . log ( `ℹ️ No dependencies found to install for ${ packages . join ( ', ' ) } .` )
4304
4269
}
4305
4270
0 commit comments