2
2
import { Buffer } from 'node:buffer'
3
3
import { execSync } from 'node:child_process'
4
4
import fs from 'node:fs'
5
- import os , { arch , platform } from 'node:os'
5
+ import { arch , platform } from 'node:os'
6
6
import path from 'node:path'
7
7
import process from 'node:process'
8
8
import { aliases , packages } from 'ts-pkgx'
@@ -2227,7 +2227,14 @@ export async function downloadPackage(
2227
2227
// Validate package completeness and trigger source build if incomplete
2228
2228
const isValidPackage = await validatePackageInstallation ( packageDir , domain )
2229
2229
if ( ! isValidPackage ) {
2230
- logUniqueMessage ( `⚠️ Package ${ domain } appears incomplete, source build not available...` )
2230
+ // Some packages like ca-certs don't have traditional binaries, so this is expected
2231
+ if ( domain . includes ( 'ca-certs' ) ) {
2232
+ if ( config . verbose ) {
2233
+ logUniqueMessage ( `ℹ️ ${ domain } installed (certificate bundle, no binaries expected)` )
2234
+ }
2235
+ } else {
2236
+ logUniqueMessage ( `⚠️ Package ${ domain } appears incomplete, source build not available...` )
2237
+ }
2231
2238
}
2232
2239
2233
2240
// Find binaries and create shims
@@ -4165,6 +4172,8 @@ export async function installDependenciesOnly(packages: string[], installPath?:
4165
4172
await fs . promises . mkdir ( targetPath , { recursive : true } )
4166
4173
4167
4174
const allInstalledFiles : string [ ] = [ ]
4175
+ let totalDepsProcessed = 0
4176
+ let totalDepsAlreadyInstalled = 0
4168
4177
4169
4178
try {
4170
4179
// Import pantry from ts-pkgx to get package dependencies
@@ -4175,12 +4184,23 @@ export async function installDependenciesOnly(packages: string[], installPath?:
4175
4184
const domain = resolvePackageName ( packageName )
4176
4185
4177
4186
// Try different ways to find the package in pantry
4178
- const packageKey = Object . keys ( pantry ) . find ( key =>
4179
- key === domain
4180
- || key === packageName
4181
- || key . includes ( packageName )
4182
- || key . includes ( domain . split ( '.' ) [ 0 ] ) ,
4183
- )
4187
+ // For PHP, we need to check php.net specifically
4188
+ let packageKey : string | undefined
4189
+
4190
+ // First, try exact matches
4191
+ packageKey = Object . keys ( pantry ) . find ( key => key === domain || key === packageName )
4192
+
4193
+ // Handle PHP special case - check phpnet specifically
4194
+ if ( ! packageKey && packageName === 'php' ) {
4195
+ packageKey = Object . keys ( pantry ) . find ( key => key === 'phpnet' )
4196
+ }
4197
+
4198
+ // Fallback to partial matches only if no exact match found
4199
+ if ( ! packageKey ) {
4200
+ packageKey = Object . keys ( pantry ) . find ( key =>
4201
+ key . includes ( packageName ) || key . includes ( domain . split ( '.' ) [ 0 ] )
4202
+ )
4203
+ }
4184
4204
4185
4205
const packageSpec = packageKey ? pantry [ packageKey ] : null
4186
4206
@@ -4190,56 +4210,72 @@ export async function installDependenciesOnly(packages: string[], installPath?:
4190
4210
}
4191
4211
4192
4212
if ( config . verbose ) {
4193
- console . warn ( ` ${ packageName } dependencies: ${ packageSpec . dependencies . join ( ', ' ) } `)
4213
+ console . log ( `📋 ${ packageName } has ${ packageSpec . dependencies . length } dependencies: ${ packageSpec . dependencies . join ( ', ' ) } `)
4194
4214
}
4195
4215
4196
- // Filter out problematic dependencies that cause builds to hang
4216
+ // Filter out problematic dependencies - these are now included since source builds don't exist
4197
4217
const skipPatterns = [
4198
- 'zlib.net' , // Causes build failures
4199
- 'libzip.org' , // Complex build
4200
- 'gnome.org/libxslt' , // Complex build
4201
- 'libpng.org' , // Complex build
4202
- 'google.com/webp' , // Complex build
4203
- 'ijg.org' , // Complex build
4204
- 'gnu.org/gmp' , // Let ts-pkgx handle GMP instead of custom build
4218
+ // Only skip dependencies that are truly problematic or incompatible
4205
4219
]
4206
4220
4207
4221
const filteredDeps = packageSpec . dependencies . filter ( dep =>
4208
4222
! skipPatterns . some ( pattern => dep . includes ( pattern ) ) ,
4209
4223
)
4210
4224
4211
4225
if ( filteredDeps . length === 0 ) {
4212
- console . log ( `✅ No dependencies to install for ${ packageName } ` )
4226
+ console . log ( `✅ No installable dependencies found for ${ packageName } ` )
4213
4227
continue
4214
4228
}
4215
4229
4216
- // Filter out already installed dependencies
4230
+ // Filter out already installed dependencies and the main package itself
4217
4231
const depsToInstall = filteredDeps . filter ( ( dep ) => {
4218
- const depInstallPath = path . join ( targetPath , dep . split ( / [ < > = ~ ^ ] / ) [ 0 ] )
4232
+ const depDomain = dep . split ( / [ < > = ~ ^ ] / ) [ 0 ]
4233
+
4234
+ // 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' ) ) {
4238
+ if ( config . verbose ) {
4239
+ console . log ( `⏭️ Skipping ${ dep } (this is the main package, not a dependency)` )
4240
+ }
4241
+ return false
4242
+ }
4243
+
4244
+ const depInstallPath = path . join ( targetPath , depDomain )
4219
4245
const alreadyInstalled = fs . existsSync ( depInstallPath )
4220
- if ( alreadyInstalled && config . verbose ) {
4221
- console . log ( `✅ ${ dep } already installed` )
4246
+ if ( alreadyInstalled ) {
4247
+ totalDepsAlreadyInstalled ++
4248
+ if ( config . verbose ) {
4249
+ console . log ( `✅ ${ dep } already installed` )
4250
+ }
4222
4251
}
4223
4252
return ! alreadyInstalled
4224
4253
} )
4225
4254
4255
+ totalDepsProcessed += filteredDeps . length
4256
+
4226
4257
if ( depsToInstall . length === 0 ) {
4227
- console . log ( `✅ All dependencies for ${ packageName } already installed` )
4258
+ if ( config . verbose ) {
4259
+ console . log ( `✅ All ${ filteredDeps . length } dependencies for ${ packageName } already installed` )
4260
+ }
4228
4261
continue
4229
4262
}
4230
4263
4231
- console . log ( `📦 Installing ${ depsToInstall . length } dependencies for ${ packageName } ...` )
4264
+ console . log ( `📦 Installing ${ depsToInstall . length } new dependencies for ${ packageName } ...` )
4265
+ if ( config . verbose ) {
4266
+ console . log ( ` Dependencies to install: ${ depsToInstall . join ( ', ' ) } ` )
4267
+ }
4232
4268
4233
4269
try {
4234
4270
// Install dependencies using the main install function
4235
4271
const installedFiles = await install ( depsToInstall , targetPath )
4236
4272
allInstalledFiles . push ( ...installedFiles )
4237
4273
4238
4274
if ( config . verbose ) {
4239
- console . log ( `✅ Installed ${ packageName } dependencies: ${ depsToInstall . join ( ', ' ) } ` )
4275
+ console . log ( `✅ Successfully installed ${ depsToInstall . length } dependencies for ${ packageName } ` )
4240
4276
}
4241
- }
4242
- catch ( error ) {
4277
+ }
4278
+ catch ( error ) {
4243
4279
console . warn ( `⚠️ Some dependencies for ${ packageName } failed to install, trying individual installation` )
4244
4280
4245
4281
// Fallback to individual installation
@@ -4258,7 +4294,15 @@ export async function installDependenciesOnly(packages: string[], installPath?:
4258
4294
}
4259
4295
}
4260
4296
4261
- console . log ( `🎉 Dependencies installation complete. ${ allInstalledFiles . length } files installed.` )
4297
+ // Improved final message
4298
+ if ( allInstalledFiles . length > 0 ) {
4299
+ console . log ( `🎉 Dependencies installation complete. Installed ${ allInstalledFiles . length } files for ${ packages . join ( ', ' ) } .` )
4300
+ } else if ( totalDepsAlreadyInstalled > 0 ) {
4301
+ console . log ( `✅ All ${ totalDepsAlreadyInstalled } dependencies for ${ packages . join ( ', ' ) } were already installed.` )
4302
+ } else {
4303
+ console . log ( `ℹ️ No dependencies found to install for ${ packages . join ( ', ' ) } .` )
4304
+ }
4305
+
4262
4306
return allInstalledFiles
4263
4307
}
4264
4308
catch ( error ) {
0 commit comments