Skip to content

Commit bb44857

Browse files
committed
chore: wip
1 parent c89d4c4 commit bb44857

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

packages/launchpad/bin/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ cli
11751175
dryrun: options?.dryRun || false,
11761176
quiet: options?.quiet || false,
11771177
shellOutput: options?.shell || false,
1178-
skipGlobal: process.env.NODE_ENV === 'test', // Skip global packages in test environment
1178+
skipGlobal: process.env.NODE_ENV === 'test' || process.env.LAUNCHPAD_SKIP_GLOBAL_AUTO_SCAN === 'true', // Skip global packages in test environment or when explicitly disabled
11791179
})
11801180
}
11811181
catch (error) {

packages/launchpad/src/dev/dump.ts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ function cacheSniffResult(projectHash: string, sniffResult: any): void {
407407
}
408408

409409
export async function dump(dir: string, options: DumpOptions = {}): Promise<void> {
410-
const { dryrun = false, quiet = false, shellOutput = false, skipGlobal = process.env.NODE_ENV === 'test' } = options
410+
const { dryrun = false, quiet = false, shellOutput = false, skipGlobal = process.env.NODE_ENV === 'test' || process.env.LAUNCHPAD_SKIP_GLOBAL_AUTO_SCAN === 'true' } = options
411411

412412
try {
413413
// Find dependency file
@@ -758,6 +758,10 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
758758
else if (!quiet && !isShellIntegration) {
759759
console.log(`🌍 Installing ${globalPackages.length} global packages...`)
760760
}
761+
else if (isShellIntegration && !quiet) {
762+
// Show progress for shell integration but keep it clean
763+
process.stderr.write(`\r🌍 Installing ${globalPackages.length} global packages...`)
764+
}
761765

762766
try {
763767
// If global environment is already ready, just create/update stubs
@@ -809,12 +813,19 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
809813
const originalShowShellMessages = config.showShellMessages
810814
const isShellIntegration = process.env.LAUNCHPAD_SHELL_INTEGRATION === '1'
811815

816+
const projectName = path.basename(dir)
817+
const startTime = Date.now()
818+
812819
if (shellOutput && !isShellIntegration) {
813820
config.showShellMessages = false
814-
const projectName = path.basename(dir)
815-
const startTime = Date.now()
816821
process.stderr.write(`🔧 Setting up project environment for ${projectName}...\n`)
822+
}
823+
else if (isShellIntegration && !quiet) {
824+
// Show progress for shell integration but keep it clean
825+
process.stderr.write(`\r🔧 Setting up project environment for ${projectName}...`)
826+
}
817827

828+
if (shellOutput && !isShellIntegration) {
818829
// Set up progress tracking for shell mode
819830
const originalStdoutWrite = process.stdout.write.bind(process.stdout)
820831
const originalConsoleLog = console.log.bind(console)
@@ -1178,22 +1189,22 @@ function outputShellCode(dir: string, envBinPath: string, envSbinPath: string, p
11781189
// Build PATH with both project and global environments
11791190
const pathComponents = []
11801191

1181-
// Add global paths first to ensure critical tools like bash are always available
1182-
if (globalBinPath && fs.existsSync(globalBinPath)) {
1183-
pathComponents.push(globalBinPath)
1184-
}
1185-
if (globalSbinPath && fs.existsSync(globalSbinPath)) {
1186-
pathComponents.push(globalSbinPath)
1187-
}
1188-
1189-
// Add project-specific paths second (can override global if needed)
1192+
// Add project-specific paths first (highest priority - can override global versions)
11901193
if (fs.existsSync(envBinPath)) {
11911194
pathComponents.push(envBinPath)
11921195
}
11931196
if (fs.existsSync(envSbinPath)) {
11941197
pathComponents.push(envSbinPath)
11951198
}
11961199

1200+
// Add global paths second (fallback for tools not in project environment)
1201+
if (globalBinPath && fs.existsSync(globalBinPath)) {
1202+
pathComponents.push(globalBinPath)
1203+
}
1204+
if (globalSbinPath && fs.existsSync(globalSbinPath)) {
1205+
pathComponents.push(globalSbinPath)
1206+
}
1207+
11971208
// Add original PATH
11981209
pathComponents.push('$LAUNCHPAD_ORIGINAL_PATH')
11991210

packages/launchpad/src/dev/shellcode.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,11 @@ __launchpad_chpwd() {
293293
# Ensure global dependencies are available first
294294
__launchpad_setup_global_deps
295295
296-
# Capture both stdout and stderr for clean output management
297-
{
298-
# Create temp files for stdout and stderr
296+
# First install packages with visible progress messages (stderr visible, stdout hidden)
297+
if LAUNCHPAD_SHELL_INTEGRATION=1 LAUNCHPAD_ORIGINAL_PATH="$LAUNCHPAD_ORIGINAL_PATH" ${launchpadBinary} dev "$project_dir" >/dev/null; then
298+
# Installation succeeded, now get shell environment
299299
local temp_file=$(mktemp)
300-
local temp_stderr=$(mktemp)
301-
302-
# Run setup command silently, capturing both streams
303-
if LAUNCHPAD_SHELL_INTEGRATION=1 LAUNCHPAD_ORIGINAL_PATH="$LAUNCHPAD_ORIGINAL_PATH" ${launchpadBinary} dev "$project_dir" --shell > "$temp_file" 2> "$temp_stderr"; then
300+
if LAUNCHPAD_SHELL_INTEGRATION=1 LAUNCHPAD_ORIGINAL_PATH="$LAUNCHPAD_ORIGINAL_PATH" ${launchpadBinary} dev "$project_dir" --shell > "$temp_file" 2>/dev/null; then
304301
# Extract shell code from stdout for evaluation
305302
if [[ -s "$temp_file" ]]; then
306303
env_output=$(cat "$temp_file" | ${grepFilter})
@@ -312,8 +309,10 @@ __launchpad_chpwd() {
312309
else
313310
setup_exit_code=$?
314311
fi
315-
rm -f "$temp_file" "$temp_stderr" 2>/dev/null || true
316-
}
312+
rm -f "$temp_file" 2>/dev/null || true
313+
else
314+
setup_exit_code=$?
315+
fi
317316
318317
# Clear the in-progress flag
319318
__launchpad_setup_in_progress=""

0 commit comments

Comments
 (0)