Skip to content

Commit d6ad98d

Browse files
committed
chore: wip
1 parent 594485f commit d6ad98d

File tree

4 files changed

+25
-57
lines changed

4 files changed

+25
-57
lines changed

packages/launchpad/src/dev-setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
import { spawn } from 'node:child_process'
23
import fs from 'node:fs'
34
import path from 'node:path'

packages/launchpad/src/install.ts

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,6 @@ import { install_bun } from './bun'
1010
import { config } from './config'
1111
import { Path } from './path'
1212

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-
5113
// Global message deduplication for shell mode
5214
const shellModeMessageCache = new Set<string>()
5315
let hasTemporaryProcessingMessage = false
@@ -2232,7 +2194,8 @@ export async function downloadPackage(
22322194
if (config.verbose) {
22332195
logUniqueMessage(`ℹ️ ${domain} installed (certificate bundle, no binaries expected)`)
22342196
}
2235-
} else {
2197+
}
2198+
else {
22362199
logUniqueMessage(`⚠️ Package ${domain} appears incomplete, source build not available...`)
22372200
}
22382201
}
@@ -2938,7 +2901,7 @@ async function installPackage(packageName: string, packageSpec: string, installP
29382901
let actualPackageSpec = packageSpec
29392902
const osMatch = packageSpec.match(/^(darwin|linux|windows|freebsd|openbsd|netbsd)@([^:]+)(:.*)?$/)
29402903
if (osMatch) {
2941-
const [, osPrefix, basePkg, versionConstraint] = osMatch
2904+
const [, _osPrefix, basePkg, versionConstraint] = osMatch
29422905
// Fix malformed version constraints: ": ^1" -> "@^1"
29432906
if (versionConstraint) {
29442907
const cleanVersion = versionConstraint.replace(/^:\s*/, '@')
@@ -4198,7 +4161,7 @@ export async function installDependenciesOnly(packages: string[], installPath?:
41984161
// Fallback to partial matches only if no exact match found
41994162
if (!packageKey) {
42004163
packageKey = Object.keys(pantry).find(key =>
4201-
key.includes(packageName) || key.includes(domain.split('.')[0])
4164+
key.includes(packageName) || key.includes(domain.split('.')[0]),
42024165
)
42034166
}
42044167

@@ -4232,9 +4195,9 @@ export async function installDependenciesOnly(packages: string[], installPath?:
42324195
const depDomain = dep.split(/[<>=~^]/)[0]
42334196

42344197
// 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')) {
42384201
if (config.verbose) {
42394202
console.log(`⏭️ Skipping ${dep} (this is the main package, not a dependency)`)
42404203
}
@@ -4252,7 +4215,7 @@ export async function installDependenciesOnly(packages: string[], installPath?:
42524215
return !alreadyInstalled
42534216
})
42544217

4255-
totalDepsProcessed += filteredDeps.length
4218+
// totalDepsProcessed += filteredDeps.length
42564219

42574220
if (depsToInstall.length === 0) {
42584221
if (config.verbose) {
@@ -4274,8 +4237,8 @@ export async function installDependenciesOnly(packages: string[], installPath?:
42744237
if (config.verbose) {
42754238
console.log(`✅ Successfully installed ${depsToInstall.length} dependencies for ${packageName}`)
42764239
}
4277-
}
4278-
catch (error) {
4240+
}
4241+
catch {
42794242
console.warn(`⚠️ Some dependencies for ${packageName} failed to install, trying individual installation`)
42804243

42814244
// Fallback to individual installation
@@ -4297,9 +4260,11 @@ export async function installDependenciesOnly(packages: string[], installPath?:
42974260
// Improved final message
42984261
if (allInstalledFiles.length > 0) {
42994262
console.log(`🎉 Dependencies installation complete. Installed ${allInstalledFiles.length} files for ${packages.join(', ')}.`)
4300-
} else if (totalDepsAlreadyInstalled > 0) {
4263+
}
4264+
else if (totalDepsAlreadyInstalled > 0) {
43014265
console.log(`✅ All ${totalDepsAlreadyInstalled} dependencies for ${packages.join(', ')} were already installed.`)
4302-
} else {
4266+
}
4267+
else {
43034268
console.log(`ℹ️ No dependencies found to install for ${packages.join(', ')}.`)
43044269
}
43054270

packages/launchpad/test/install-deps-only.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
import { afterEach, beforeEach, describe, expect, it, mock } from 'bun:test'
23
import fs from 'node:fs'
34
import os from 'node:os'
@@ -18,19 +19,19 @@ const mockPantry = {
1819
'postgresql.org/libpq',
1920
'zlib.net', // This should be filtered out by skipPatterns
2021
'libzip.org', // This should be filtered out by skipPatterns
21-
]
22+
],
2223
},
2324
nodejs: {
2425
dependencies: [
2526
'python.org',
26-
'gcc.gnu.org'
27-
]
28-
}
27+
'gcc.gnu.org',
28+
],
29+
},
2930
}
3031

3132
// Mock ts-pkgx import
3233
mock.module('ts-pkgx', () => ({
33-
pantry: mockPantry
34+
pantry: mockPantry,
3435
}))
3536

3637
describe('Install Dependencies Only', () => {
@@ -167,7 +168,7 @@ describe('Install Dependencies Only', () => {
167168
// Should not mention installing PHP itself, only dependencies
168169
const logCalls = mockConsoleLog.mock.calls.flat()
169170
const installMainPackage = logCalls.some(call =>
170-
call.includes('Installing php') && !call.includes('dependencies')
171+
call.includes('Installing php') && !call.includes('dependencies'),
171172
)
172173
expect(installMainPackage).toBe(false)
173174
})
@@ -207,7 +208,8 @@ describe('Install Dependencies Only', () => {
207208
// Restore original verbose setting
208209
if (originalVerbose !== undefined) {
209210
process.env.LAUNCHPAD_VERBOSE = originalVerbose
210-
} else {
211+
}
212+
else {
211213
delete process.env.LAUNCHPAD_VERBOSE
212214
}
213215
})

packages/launchpad/test/test.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class TestUtils {
106106
// Only clean project-specific environments, not global dependencies
107107
// This prevents tests from removing system-wide tools
108108
const envBaseDir = path.join(os.homedir(), '.local', 'share', 'launchpad', 'envs')
109-
const globalDir = path.join(os.homedir(), '.local', 'share', 'launchpad', 'global')
109+
const _globalDir = path.join(os.homedir(), '.local', 'share', 'launchpad', 'global')
110110

111111
// CRITICAL: Never touch the global directory in tests
112112
if (!fs.existsSync(envBaseDir)) {

0 commit comments

Comments
 (0)