Skip to content

Commit 13d31ed

Browse files
committed
chore: wip
1 parent d6d7bea commit 13d31ed

File tree

1 file changed

+54
-6
lines changed

1 file changed

+54
-6
lines changed

packages/launchpad/src/install.ts

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,52 @@ export function resetInstalledTracker(): void {
2525
globalCompletedPackages.clear()
2626
}
2727

28+
/**
29+
* Resolve critical system library conflicts (like OpenSSL) to prevent runtime issues
30+
*/
31+
function resolveCriticalLibraryConflicts(packages: string[]): string[] {
32+
const packageMap = new Map<string, string>()
33+
const criticalLibraries = new Set(['openssl.org', 'libssl', 'libcrypto'])
34+
35+
// First pass: collect all packages
36+
for (const pkg of packages) {
37+
const { name } = parsePackageSpec(pkg)
38+
const domain = resolvePackageName(name)
39+
packageMap.set(domain, pkg)
40+
}
41+
42+
// Second pass: resolve critical library conflicts
43+
for (const domain of criticalLibraries) {
44+
if (packageMap.has(domain)) {
45+
const pkg = packageMap.get(domain)!
46+
const { version } = parsePackageSpec(pkg)
47+
48+
// Force OpenSSL to use 1.1.1w for maximum compatibility
49+
if (domain === 'openssl.org') {
50+
// Always prefer OpenSSL 1.1.1w for compatibility with most software
51+
const compatiblePkg = `[email protected]`
52+
packageMap.set(domain, compatiblePkg)
53+
if (config.verbose) {
54+
console.warn(`🔒 Resolved OpenSSL conflict: ${pkg} -> ${compatiblePkg} for maximum compatibility`)
55+
}
56+
}
57+
}
58+
}
59+
60+
return Array.from(packageMap.values())
61+
}
62+
2863
// Use ts-pkgx API to resolve all dependencies with proper version conflict resolution
2964
export async function resolveAllDependencies(packages: string[]): Promise<string[]> {
65+
// First resolve critical library conflicts
66+
const conflictResolvedPackages = resolveCriticalLibraryConflicts(packages)
67+
3068
try {
3169
// Import resolveDependencies from ts-pkgx
3270
const { resolveDependencies } = await import('ts-pkgx')
3371

34-
// Create a temporary dependency file content
35-
const depsYaml = packages.reduce((acc, pkg) => {
72+
// Create a temporary dependency file content using conflict-resolved packages
73+
const depsYaml = conflictResolvedPackages.reduce((acc, pkg) => {
3674
const { name, version } = parsePackageSpec(pkg)
3775
acc[name] = version || '*'
3876
return acc
@@ -84,7 +122,7 @@ export async function resolveAllDependencies(packages: string[]): Promise<string
84122
console.warn(`Failed to use ts-pkgx for dependency resolution: ${error instanceof Error ? error.message : String(error)}`)
85123
console.warn('Falling back to simple deduplication...')
86124
}
87-
return deduplicatePackagesByVersion(packages)
125+
return deduplicatePackagesByVersion(conflictResolvedPackages)
88126
}
89127
}
90128

@@ -2603,8 +2641,14 @@ async function installDependencies(
26032641
// Strategy 3: Check for well-known version compatibility mappings
26042642
const versionCompatibilityMap: Record<string, Record<string, string[]>> = {
26052643
'openssl.org': {
2606-
'^1.1': ['3.5.0', '3.4.0', '3.3.2'], // OpenSSL 3.x is backward compatible with 1.x APIs
2607-
'^1.0': ['3.5.0', '3.4.0', '3.3.2'],
2644+
// CORRECTED: OpenSSL 3.x is NOT backward compatible with 1.x due to ABI changes
2645+
// Instead, prefer 1.x versions for broader compatibility
2646+
'^3.0': ['1.1.1w', '1.1.1u', '1.1.1t'], // Prefer stable 1.1.1 for compatibility
2647+
'^3.1': ['1.1.1w', '1.1.1u', '1.1.1t'],
2648+
'^3.2': ['1.1.1w', '1.1.1u', '1.1.1t'],
2649+
'^3.3': ['1.1.1w', '1.1.1u', '1.1.1t'],
2650+
'^3.4': ['1.1.1w', '1.1.1u', '1.1.1t'],
2651+
'^3.5': ['1.1.1w', '1.1.1u', '1.1.1t'],
26082652
},
26092653
'zlib.net': {
26102654
'^1.2': ['1.3.1', '1.3.0'], // zlib 1.3.x is compatible with 1.2.x
@@ -2967,7 +3011,11 @@ export async function install(packages: PackageSpec | PackageSpec[], basePath?:
29673011
}
29683012

29693013
// Use ts-pkgx to resolve all dependencies with proper version conflict resolution
2970-
const resolvedPackages = await resolveAllDependencies(packageList)
3014+
let resolvedPackages = await resolveAllDependencies(packageList)
3015+
3016+
// Apply critical library conflict resolution again in case global packages interfere
3017+
resolvedPackages = resolveCriticalLibraryConflicts(resolvedPackages)
3018+
29713019
const deduplicatedPackages = resolvedPackages
29723020

29733021
// Skip recursive dependency resolution since ts-pkgx already resolved everything

0 commit comments

Comments
 (0)