Skip to content

Commit 8f20e4b

Browse files
committed
chore: wip
1 parent 375e818 commit 8f20e4b

File tree

8 files changed

+369
-70
lines changed

8 files changed

+369
-70
lines changed

bun.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"dependencies": {
4242
"bunfig": "^0.10.1",
4343
"cac": "^6.7.14",
44-
"ts-pkgx": "0.4.4",
44+
"ts-pkgx": "0.4.15",
4545
},
4646
"devDependencies": {
4747
"bun-plugin-dtsx": "^0.9.5",
@@ -1875,7 +1875,7 @@
18751875

18761876
"ts-declaration-location": ["[email protected]", "", { "dependencies": { "picomatch": "^4.0.2" }, "peerDependencies": { "typescript": ">=4.0.0" } }, "sha512-EDyGAwH1gO0Ausm9gV6T2nUvBgXT5kGoCMJPllOaooZ+4VvJiKBdZE7wK18N1deEowhcUptS+5GXZK8U/fvpwA=="],
18771877

1878-
"ts-pkgx": ["[email protected].4", "", { "dependencies": { "chromium-bidi": "^7.2.0", "electron": "^37.2.4", "js-yaml": "^4.1.0", "playwright": "^1.54.1" }, "bin": { "pkgx-tools": "dist/bin/cli.js" } }, "sha512-1ybeSxPjlB3VYp/2mmDx7aTlkH8RQsKs7CONXWyiJXmV+hDqPuCCI4bsdirnspW+iReZiThBa6wIaPM4+KlnQQ=="],
1878+
"ts-pkgx": ["[email protected].15", "", { "dependencies": { "chromium-bidi": "^7.2.0", "electron": "^37.2.4", "js-yaml": "^4.1.0", "playwright": "^1.54.1" }, "bin": { "pkgx-tools": "dist/bin/cli.js" } }, "sha512-A0SaaYXSrXfgd8aWDZRY6/8XVNS1FGSQtGgUgnSuvCdvKOTwz6JofZtUo0BYJQuO640BIPhftKnx4biQhZC0QQ=="],
18791879

18801880
"tslib": ["[email protected]", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
18811881

packages/launchpad/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"dependencies": {
6666
"bunfig": "^0.10.1",
6767
"cac": "^6.7.14",
68-
"ts-pkgx": "0.4.4"
68+
"ts-pkgx": "0.4.15"
6969
},
7070
"devDependencies": {
7171
"bun-plugin-dtsx": "^0.9.5"

packages/launchpad/src/dev/dump.ts

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import path from 'node:path'
66
import process from 'node:process'
77
import { config } from '../config'
88
import { findDependencyFile } from '../env'
9-
import { install } from '../install'
9+
import { install, resetInstalledTracker } from '../install'
1010

1111
// Utility functions
1212
function generateProjectHash(projectPath: string): string {
@@ -158,8 +158,8 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
158158
const isShellIntegration = process.env.LAUNCHPAD_SHELL_INTEGRATION === '1'
159159
const effectiveQuiet = quiet || isShellIntegration
160160

161-
// For shell integration, suppress ALL output except essential messages
162-
if (isShellIntegration) {
161+
// For shell integration, only suppress output if in quiet mode
162+
if (isShellIntegration && quiet) {
163163
const originalStderrWrite = process.stderr.write.bind(process.stderr)
164164
const originalConsoleLog = console.log.bind(console)
165165

@@ -174,12 +174,17 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
174174
|| message.includes('⚠️') // Warnings
175175
|| message.includes('❌') // Errors
176176
|| message.includes('%') // Progress percentages
177-
|| message.includes('bytes')) { // Download bytes
177+
|| message.includes('bytes') // Download bytes
178+
|| message.includes('Installing') // Installation messages
179+
|| message.includes('Downloading') // Download start messages
180+
|| message.includes('Extracting') // Extraction messages
181+
|| message.startsWith('\r')) { // Allow carriage return progress updates
178182
return originalStderrWrite(chunk, encoding, cb)
179183
}
180-
// Suppress setup messages and other verbose output
181-
if (typeof cb === 'function')
182-
cb()
184+
// Suppress setup messages and other verbose output - call callback to signal completion
185+
if (typeof cb === 'function') {
186+
process.nextTick(cb)
187+
}
183188
return true
184189
} as any
185190

@@ -469,12 +474,35 @@ async function installPackagesOptimized(
469474
): Promise<void> {
470475
const isShellIntegration = process.env.LAUNCHPAD_SHELL_INTEGRATION === '1'
471476

477+
// Reset the global installed packages tracker for this environment setup
478+
resetInstalledTracker()
479+
480+
// Add progress indicator for shell integration
481+
let progressInterval: NodeJS.Timeout | null = null
482+
if (isShellIntegration && (localPackages.length > 0 || globalPackages.length > 0)) {
483+
const dots = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
484+
let dotIndex = 0
485+
progressInterval = setInterval(() => {
486+
process.stderr.write(`\r${dots[dotIndex]} Installing packages...`)
487+
dotIndex = (dotIndex + 1) % dots.length
488+
}, 150)
489+
}
490+
472491
// Install global packages first (if any)
473492
if (globalPackages.length > 0) {
474493
if (!quiet && !isShellIntegration) {
475494
console.log(`Installing ${globalPackages.length} global packages...`)
476495
}
477496

497+
// Clear spinner before starting installation to avoid overlap
498+
if (progressInterval) {
499+
clearInterval(progressInterval)
500+
progressInterval = null
501+
if (isShellIntegration) {
502+
process.stderr.write('\r\x1B[K')
503+
}
504+
}
505+
478506
try {
479507
// For both shell integration and regular calls, use standard install
480508
await install(globalPackages, globalEnvDir)
@@ -499,6 +527,15 @@ async function installPackagesOptimized(
499527
console.log(`Installing ${localPackages.length} local packages...`)
500528
}
501529

530+
// Clear spinner before starting installation to avoid overlap (if not already cleared)
531+
if (progressInterval) {
532+
clearInterval(progressInterval)
533+
progressInterval = null
534+
if (isShellIntegration) {
535+
process.stderr.write('\r\x1B[K')
536+
}
537+
}
538+
502539
try {
503540
// For both shell integration and regular calls, use standard install
504541
await install(localPackages, envDir)
@@ -516,6 +553,15 @@ async function installPackagesOptimized(
516553
}
517554
}
518555
}
556+
557+
// Clean up progress indicator (final safety check)
558+
if (progressInterval) {
559+
clearInterval(progressInterval)
560+
progressInterval = null
561+
if (isShellIntegration) {
562+
process.stderr.write('\r\x1B[K')
563+
}
564+
}
519565
}
520566

521567
function outputShellCode(dir: string, envBinPath: string, envSbinPath: string, projectHash: string, sniffResult?: any, globalBinPath?: string, globalSbinPath?: string): void {

packages/launchpad/src/dev/shellcode.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -504,18 +504,12 @@ __launchpad_chpwd() {
504504
return 0
505505
fi
506506
507-
# Skip setup if we've had too many timeouts
508-
if [[ $__launchpad_timeout_count -gt 2 ]]; then
509-
if [[ "\$\{LAUNCHPAD_SHOW_ENV_MESSAGES:-${showMessages}\}" != "false" ]]; then
510-
echo "⚡ Environment setup temporarily disabled (timeout protection)" >&2
511-
fi
512-
return 0
513-
fi
507+
# Continue with setup
514508
515509
# Mark setup as in progress
516510
__launchpad_setup_in_progress="$project_dir"
517511
518-
# Show immediate feedback
512+
# Show immediate feedback
519513
if [[ "\$\{LAUNCHPAD_SHOW_ENV_MESSAGES:-${showMessages}\}" != "false" ]]; then
520514
printf "🔧 Setting up environment for \\033[3m$(basename "$project_dir")\\033[0m...\\r" >&2
521515
fi
@@ -527,29 +521,34 @@ __launchpad_chpwd() {
527521
# Ensure global dependencies are available first
528522
__launchpad_setup_global_deps
529523
530-
# Ultra-fast setup: use shell mode with reasonable timeout for package installation
524+
# Run environment setup without timeout - let it take as long as needed
531525
local temp_file=$(mktemp)
532-
if timeout 30 ${launchpadBinary} dev "$project_dir" --shell --quiet > "$temp_file" 2>&1; then
533-
env_output=$(cat "$temp_file" | ${grepFilter})
534-
setup_exit_code=0
526+
527+
# Run with real-time progress display - show progress on stderr, capture shell code on stdout
528+
if [[ "\$\{LAUNCHPAD_SHOW_ENV_MESSAGES:-${showMessages}\}" != "false" ]]; then
529+
# Show progress in real-time while capturing output
530+
${launchpadBinary} dev "$project_dir" --shell > "$temp_file"
535531
else
536-
setup_exit_code=$?
532+
# Quiet mode - suppress all output
533+
${launchpadBinary} dev "$project_dir" --shell --quiet > "$temp_file" 2>/dev/null
537534
fi
535+
setup_exit_code=$?
536+
537+
# Extract shell code from output
538+
env_output=$(cat "$temp_file" | ${grepFilter})
538539
rm -f "$temp_file" 2>/dev/null || true
539540
540541
# Clear the in-progress flag
541542
__launchpad_setup_in_progress=""
542543
543-
if [[ $setup_exit_code -eq 124 ]]; then
544-
# Timeout occurred
545-
__launchpad_timeout_count=$(((__launchpad_timeout_count + 1)))
544+
if [[ $setup_exit_code -eq 130 ]]; then
545+
# User interrupted with Ctrl+C
546546
if [[ "\$\{LAUNCHPAD_SHOW_ENV_MESSAGES:-${showMessages}\}" != "false" ]]; then
547-
printf "\\r\\033[K⚠️ Environment setup timed out for $(basename "$project_dir")\\n" >&2
547+
printf "\\r\\033[K⚠️ Environment setup cancelled\\n" >&2
548548
fi
549-
return 0
549+
return 130
550550
elif [[ $setup_exit_code -eq 0 ]]; then
551-
# Success - reset timeout counter
552-
__launchpad_timeout_count=0
551+
# Success
553552
554553
# Execute the environment setup if we have output
555554
if [[ -n "$env_output" ]]; then

packages/launchpad/src/doctor.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ async function checkInstallationDirectory(): Promise<DiagnosticResult> {
135135
name: 'Installation Directory',
136136
status: 'fail',
137137
message: `Error checking installation directory: ${error instanceof Error ? error.message : String(error)}`,
138+
suggestion: 'Try running "launchpad bootstrap" to reinitialize the installation',
138139
}
139140
}
140141
}
@@ -186,6 +187,7 @@ async function checkPathConfiguration(): Promise<DiagnosticResult> {
186187
name: 'PATH Configuration',
187188
status: 'fail',
188189
message: `Error checking PATH configuration: ${error instanceof Error ? error.message : String(error)}`,
190+
suggestion: 'Check your shell configuration files and PATH environment variable',
189191
}
190192
}
191193
}
@@ -224,6 +226,7 @@ async function checkShimDirectory(): Promise<DiagnosticResult> {
224226
name: 'Shim Directory',
225227
status: 'fail',
226228
message: `Error checking shim directory: ${error instanceof Error ? error.message : String(error)}`,
229+
suggestion: 'Check directory permissions and reinstall launchpad if necessary',
227230
}
228231
}
229232
}
@@ -274,6 +277,7 @@ async function checkPermissions(): Promise<DiagnosticResult> {
274277
name: 'Permissions',
275278
status: 'fail',
276279
message: `Error checking permissions: ${error instanceof Error ? error.message : String(error)}`,
280+
suggestion: 'Check file and directory permissions for your home directory and launchpad installation',
277281
}
278282
}
279283
}
@@ -325,6 +329,7 @@ async function checkShellIntegration(): Promise<DiagnosticResult> {
325329
name: 'Shell Integration',
326330
status: 'fail',
327331
message: `Error checking shell integration: ${error instanceof Error ? error.message : String(error)}`,
332+
suggestion: 'Try running "launchpad dev:shellcode" to regenerate shell integration or check your shell configuration',
328333
}
329334
}
330335
}
@@ -380,6 +385,7 @@ async function checkSystemDependencies(): Promise<DiagnosticResult> {
380385
name: 'System Dependencies',
381386
status: 'fail',
382387
message: `Error checking system dependencies: ${error instanceof Error ? error.message : String(error)}`,
388+
suggestion: 'Install required system tools using your system package manager (brew, apt, yum, etc.)',
383389
}
384390
}
385391
}
@@ -503,6 +509,7 @@ async function checkPhpExtensions(): Promise<DiagnosticResult> {
503509
name: 'PHP Extensions',
504510
status: 'fail',
505511
message: `Error checking PHP extensions: ${error instanceof Error ? error.message : String(error)}`,
512+
suggestion: 'Install PHP and required extensions, or check PHP configuration',
506513
}
507514
}
508515
}

0 commit comments

Comments
 (0)