Skip to content

Commit b1e3401

Browse files
committed
chore: wip
1 parent 2450f1e commit b1e3401

File tree

5 files changed

+50
-106
lines changed

5 files changed

+50
-106
lines changed

deps.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
dependencies:
2-
bun.com: 1.2.21
2+
bun.com: 1.2.19

launchpad.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { LaunchpadConfig } from './packages/launchpad/src'
22

33
const config: Partial<LaunchpadConfig> = {
4-
verbose: true,
4+
verbose: false,
55
showShellMessages: true,
66
}
77

packages/launchpad/src/commands/install.ts

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,22 @@ async function ensureShellIntegrationInstalled(): Promise<void> {
9191
}
9292
}
9393
if (!found) {
94-
const { default: integrate } = await import('../dev/integrate')
95-
await integrate('install', { dryrun: false })
94+
// Run shell integration installation with timeout to prevent hanging
95+
const timeoutPromise = new Promise<void>((_, reject) => {
96+
setTimeout(() => reject(new Error('Shell integration timeout')), 5000)
97+
})
98+
99+
const integrationPromise = (async () => {
100+
const { default: integrate } = await import('../dev/integrate')
101+
await integrate('install', { dryrun: false })
102+
})()
103+
104+
await Promise.race([integrationPromise, timeoutPromise])
96105
}
97106
}
98-
catch {}
107+
catch {
108+
// Silently fail - shell integration is not critical for functionality
109+
}
99110
}
100111

101112
async function installPackagesGlobally(packages: string[], options: { verbose?: boolean, quiet?: boolean, noInteractive?: boolean }) {
@@ -134,10 +145,15 @@ async function installPackagesGlobally(packages: string[], options: { verbose?:
134145
console.log('✅ All specified packages were already installed globally')
135146
}
136147
}
148+
149+
// Force exit after successful completion to prevent hanging
150+
if (process.env.LAUNCHPAD_CLI_MODE === '1') {
151+
process.exit(0)
152+
}
137153
}
138154

139155
async function installGlobalDependencies(options: { dryRun?: boolean, quiet?: boolean, verbose?: boolean, noInteractive?: boolean }) {
140-
if (!options.quiet)
156+
if (options.verbose)
141157
console.log('🔍 Scanning machine for dependency files...')
142158

143159
const overallStartTime = Date.now()
@@ -284,7 +300,7 @@ async function installGlobalDependencies(options: { dryRun?: boolean, quiet?: bo
284300
console.log(` ✓ Found ${fileCount} files matching ${pattern} in ${location} (${Date.now() - startTime}ms)`)
285301
}
286302
const time = Date.now() - locationStart
287-
if (options.verbose || time > 1000)
303+
if (options.verbose)
288304
console.log(`📍 Completed ${location} in ${time}ms`)
289305
}
290306
catch (error) {
@@ -295,7 +311,7 @@ async function installGlobalDependencies(options: { dryRun?: boolean, quiet?: bo
295311
}
296312

297313
const overallTime = Date.now() - overallStartTime
298-
if (!options.quiet)
314+
if (options.verbose)
299315
console.log(`📁 Found ${foundFiles.length} dependency files in ${overallTime}ms`)
300316

301317
const { default: sniff } = await import('../dev/sniff')
@@ -325,8 +341,10 @@ async function installGlobalDependencies(options: { dryRun?: boolean, quiet?: bo
325341
return !isFake
326342
})
327343

328-
if (!options.quiet) {
344+
if (options.verbose) {
329345
console.log(`📦 Found ${filteredPackages.length} unique global dependencies`)
346+
}
347+
if (!options.quiet) {
330348
if (options.dryRun) {
331349
console.log('🔍 Packages that would be installed:')
332350
filteredPackages.forEach(pkg => console.log(` • ${pkg}`))
@@ -419,6 +437,11 @@ async function installGlobalDependencies(options: { dryRun?: boolean, quiet?: bo
419437
console.log(`🎉 Successfully installed ${filteredPackages.length} global dependencies (${results.length} binaries)`)
420438
else console.log('✅ All global dependencies were already installed')
421439
}
440+
441+
// Force exit after successful completion to prevent hanging
442+
if (process.env.LAUNCHPAD_CLI_MODE === '1') {
443+
process.exit(0)
444+
}
422445
}
423446
catch (error) {
424447
if (!options.quiet)
@@ -523,6 +546,11 @@ const command: Command = {
523546
console.log('⚠️ No binaries were installed')
524547
}
525548
}
549+
550+
// Force exit after successful completion to prevent hanging
551+
if (process.env.LAUNCHPAD_CLI_MODE === '1') {
552+
process.exit(0)
553+
}
526554
return 0
527555
}
528556
catch (err) {

packages/launchpad/src/dev/integrate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ function getShellFiles(): [string, string][] {
110110
}
111111

112112
console.error('no `.shellrc` files found')
113-
process.exit(1)
113+
// Don't exit - just return empty array to prevent hanging
114+
return []
114115
}
115116

116117
return viable_candidates

packages/launchpad/src/dev/shellcode.ts

Lines changed: 11 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ __launchpad_switch_environment() {
9797
fi
9898
export __LAUNCHPAD_LAST_VERBOSE_KEY="$__lp_verbose_key"
9999
100-
if [[ "$verbose_mode" == "true" && "$__lp_should_verbose_print" == "1" ]]; then
101-
printf "⏱️ [0ms] Shell integration started for PWD=%s\\n" "$PWD" >&2
102-
fi
100+
# Removed verbose shell integration start message
103101
104102
# Known dependency filenames (keep in sync with DEPENDENCY_FILE_NAMES in src/env.ts)
105103
local _dep_names=(
@@ -150,14 +148,7 @@ __launchpad_switch_environment() {
150148
done
151149
fi
152150
153-
# Verbose: show project detection result
154-
if [[ "$verbose_mode" == "true" && "$__lp_should_verbose_print" == "1" ]]; then
155-
if [[ -n "$project_dir" ]]; then
156-
printf "📁 Project detected: %s\n" "$project_dir" >&2
157-
else
158-
printf "📁 No project detected (global mode)\n" >&2
159-
fi
160-
fi
151+
# Removed verbose project detection message
161152
162153
# Step 2: Always ensure global paths are available (even in projects)
163154
# Use ~/.local/bin first, then launchpad global bin to ensure proper path priority
@@ -178,9 +169,7 @@ __launchpad_switch_environment() {
178169
local ready_cache_marker="$HOME/.cache/launchpad/global_ready"
179170
local ready_global_marker="$HOME/.local/share/launchpad/global/.ready"
180171
if [[ -f "$ready_cache_marker" || -f "$ready_global_marker" ]]; then
181-
if [[ "$verbose_mode" == "true" && "$__lp_should_verbose_print" == "1" ]]; then
182-
printf "♻️ Reusing existing global tools (ready marker found)\n" >&2
183-
fi
172+
# Removed verbose reuse message
184173
# No-op: presence of the marker simply informs reuse; installs remain on-demand per env needs
185174
186175
# TTL-based background update check to keep globals fresh without blocking the prompt
@@ -260,10 +249,7 @@ __launchpad_switch_environment() {
260249
fi
261250
fi
262251
263-
# Show refresh message if verbose
264-
if [[ "$verbose_mode" == "true" ]]; then
265-
printf "🔄 Shell environment refreshed for newly installed tools\n" >&2
266-
fi
252+
# Removed verbose refresh message
267253
fi
268254
269255
# Step 2.2: If a global update notice is present, display it once and remove
@@ -324,9 +310,7 @@ __launchpad_switch_environment() {
324310
fi
325311
fi
326312
327-
if [[ "$verbose_mode" == "true" && "$__lp_should_verbose_print" == "1" ]]; then
328-
printf "🔎 dep_file=%q dep_short=%s env_dir=%q\n" "$dep_file" "$dep_short" "$env_dir" >&2
329-
fi
313+
# Removed verbose dependency file info message
330314
331315
# Check if we're switching projects
332316
if [[ -n "$LAUNCHPAD_CURRENT_PROJECT" && "$LAUNCHPAD_CURRENT_PROJECT" != "$project_dir" ]]; then
@@ -350,15 +334,12 @@ __launchpad_switch_environment() {
350334
# Show activation message if enabled (only when env changes)
351335
if [[ "${showMessages}" == "true" ]]; then
352336
if [[ "$__LAUNCHPAD_LAST_ACTIVATION_KEY" != "$env_dir" ]]; then
353-
printf "${activationMessage}\\n" >&2
337+
printf "${activationMessage} " >&2
354338
fi
355339
fi
356340
export __LAUNCHPAD_LAST_ACTIVATION_KEY="$env_dir"
357341
358-
# Verbose: show activated env path
359-
if [[ "$verbose_mode" == "true" && "$__lp_should_verbose_print" == "1" ]]; then
360-
printf "✅ Activated environment: %s\n" "$env_dir" >&2
361-
fi
342+
# Removed verbose activated environment path message
362343
363344
# Ensure dynamic linker can find Launchpad-managed libraries (macOS/Linux)
364345
# Build a list of library directories from the active environment and global install
@@ -410,79 +391,12 @@ __launchpad_switch_environment() {
410391
fi
411392
done
412393
else
413-
# Non-blocking on-demand install with retry backoff (no artificial timeout)
414-
local cache_dir="$HOME/.cache/launchpad/shell_cache"
415-
mkdir -p "$cache_dir" 2>/dev/null || true
416-
local backoff_marker="$cache_dir/install_backoff_$(echo "$env_dir" | tr '/' '_')"
417-
418-
local now_s=$(date +%s 2>/dev/null || echo 0)
419-
local retry_after=600 # 10 minutes
420-
local should_attempt=1
421-
if [[ -f "$backoff_marker" ]]; then
422-
local mtime=$(date -r "$backoff_marker" +%s 2>/dev/null || echo 0)
423-
if [[ $(( now_s - mtime )) -lt $retry_after ]]; then
424-
should_attempt=0
425-
fi
426-
fi
427-
428-
if [[ "$should_attempt" -eq 1 ]]; then
429-
# Run installer; show output if verbose, otherwise suppress to keep prompt clean
430-
if [[ "$verbose_mode" == "true" && "$__lp_should_verbose_print" == "1" ]]; then
431-
printf "🚀 Starting on-demand install for %q\n" "$project_dir" >&2
432-
fi
433-
434-
if [[ "$verbose_mode" == "true" ]]; then
435-
# In verbose mode, avoid LAUNCHPAD_SHELL_INTEGRATION=1 so installer prints logs
436-
LAUNCHPAD_DISABLE_SHELL_INTEGRATION=1 ${launchpadBinary} install "$project_dir"
437-
install_status=$?
438-
else
439-
LAUNCHPAD_DISABLE_SHELL_INTEGRATION=1 LAUNCHPAD_SHELL_INTEGRATION=1 ${launchpadBinary} install "$project_dir" >/dev/null 2>&1
440-
install_status=$?
441-
fi
442-
443-
if [[ $install_status -eq 0 ]]; then
444-
if [[ "$verbose_mode" == "true" && "$__lp_should_verbose_print" == "1" ]]; then
445-
printf "📦 Installed project dependencies (on-demand)\n" >&2
446-
fi
447-
if [[ -d "$env_dir/bin" ]]; then
448-
export LAUNCHPAD_CURRENT_PROJECT="$project_dir"
449-
export LAUNCHPAD_ENV_BIN_PATH="$env_dir/bin"
450-
export PATH="$env_dir/bin:$PATH"
451-
if [[ "${showMessages}" == "true" ]]; then
452-
printf "${activationMessage}\\n" >&2
453-
fi
454-
if [[ "$verbose_mode" == "true" && "$__lp_should_verbose_print" == "1" ]]; then
455-
printf "✅ Activated environment after install: %s\n" "$env_dir" >&2
456-
fi
457-
# Clear any backoff marker after successful install
458-
rm -f "$backoff_marker" 2>/dev/null || true
459-
fi
460-
else
461-
# Touch backoff marker only on failure to avoid repeated attempts
462-
: > "$backoff_marker" 2>/dev/null || true
463-
if [[ "$verbose_mode" == "true" && "$__lp_should_verbose_print" == "1" ]]; then
464-
printf "❌ On-demand install failed (exit %d). Run 'launchpad install %q' manually.\n" "$install_status" "$project_dir" >&2
465-
fi
466-
fi
467-
else
468-
if [[ "$verbose_mode" == "true" && "$__lp_should_verbose_print" == "1" ]]; then
469-
printf "⏳ Install backoff active; not attempting on-demand install.\n" >&2
470-
fi
471-
fi
394+
# Environment not ready - skip setup during shell integration to prevent hanging
395+
# User can run 'launchpad install <project>' manually when needed
472396
fi
473397
fi
474398
475-
# Show completion time if verbose
476-
if [[ "$verbose_mode" == "true" && "$__lp_should_verbose_print" == "1" ]]; then
477-
local end_time=$(lp_now_ms)
478-
# Only print if both are integers
479-
if [[ "$start_time" =~ ^[0-9]+$ && "$end_time" =~ ^[0-9]+$ ]]; then
480-
local elapsed=$(( end_time - start_time ))
481-
if [[ "$elapsed" -ge 0 ]]; then
482-
printf "⏱️ [%sms] Shell integration completed\n" "$elapsed" >&2
483-
fi
484-
fi
485-
fi
399+
# Removed verbose shell integration completion message
486400
}
487401
488402
# CRITICAL: Prevent infinite loops - if we're already processing, exit immediately
@@ -548,6 +462,7 @@ fi
548462
# Clean up processing flag before exit
549463
unset __LAUNCHPAD_PROCESSING 2>/dev/null || true
550464
465+
# Ensure we exit cleanly and don't hang the shell
551466
return 0 2>/dev/null || exit 0`
552467
}
553468

0 commit comments

Comments
 (0)