Skip to content

Commit ac7fa1f

Browse files
committed
chore: wip
1 parent 80be6da commit ac7fa1f

File tree

3 files changed

+31
-74
lines changed

3 files changed

+31
-74
lines changed

packages/launchpad/src/bun.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,10 @@ export async function install_bun(installPath: string, version?: string): Promis
291291

292292
try {
293293
if (cachedArchivePath) {
294-
// Use cached version
294+
// Use cached version - show success message directly without intermediate loading message
295295
if (config.verbose) {
296296
console.warn(`Using cached Bun v${bunVersion} from: ${cachedArchivePath}`)
297297
}
298-
else {
299-
console.log(`📦 Using cached Bun v${bunVersion}...`)
300-
}
301298

302299
// Copy cached file to temp directory for extraction
303300
zipPath = path.join(tempDir, filename)

packages/launchpad/src/install.ts

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ function cleanupSpinner(): void {
3232
}
3333
}
3434

35+
// Function to clean up all lingering processing messages at the end
36+
function cleanupAllProcessingMessages(): void {
37+
cleanupSpinner()
38+
// Additional cleanup can be added here if needed
39+
}
40+
3541
// Setup signal handlers for clean exit
3642
function setupSignalHandlers(): void {
3743
process.on('SIGINT', () => {
@@ -103,19 +109,22 @@ function logUniqueMessage(message: string, forceLog = false): void {
103109
if (!config.verbose && message.startsWith('✅') && !message.includes('Environment activated')) {
104110
// Add a small delay to make the success message visible before showing processing message
105111
setTimeout(() => {
106-
const processingMsg = `🔄 Processing next dependency...`
112+
// Only show processing message if we haven't completed all packages
113+
if (!hasTemporaryProcessingMessage) {
114+
const processingMsg = `🔄 Processing next dependency...`
107115

108-
if (process.env.LAUNCHPAD_SHELL_INTEGRATION === '1') {
109-
process.stderr.write(`${processingMsg}\n`)
110-
if (process.stderr.isTTY) {
111-
fs.writeSync(process.stderr.fd, '')
116+
if (process.env.LAUNCHPAD_SHELL_INTEGRATION === '1') {
117+
process.stderr.write(`${processingMsg}\n`)
118+
if (process.stderr.isTTY) {
119+
fs.writeSync(process.stderr.fd, '')
120+
}
121+
}
122+
else {
123+
process.stdout.write(`${processingMsg}\n`)
112124
}
113-
}
114-
else {
115-
process.stdout.write(`${processingMsg}\n`)
116-
}
117125

118-
hasTemporaryProcessingMessage = true
126+
hasTemporaryProcessingMessage = true
127+
}
119128
}, 50) // Small delay to ensure success message is visible
120129
}
121130
}
@@ -1396,6 +1405,9 @@ export async function downloadPackage(
13961405
let archiveFile: string | null = null
13971406
let usedCache = false
13981407

1408+
// Track whether we've shown a success message to avoid redundant extraction messages
1409+
let showedSuccessMessage = false
1410+
13991411
for (const format of formats) {
14001412
// Check if we have a cached version first
14011413
const cachedArchivePath = getCachedPackagePath(domain, version, format)
@@ -1406,40 +1418,9 @@ export async function downloadPackage(
14061418
console.warn(`Using cached ${domain} v${version} from: ${cachedArchivePath}`)
14071419
}
14081420
else {
1409-
// Show a brief processing message for cached packages to provide feedback
1410-
if (!config.verbose) {
1411-
const processingMsg = `🔄 Loading ${domain} v${version} from cache...`
1412-
if (process.env.LAUNCHPAD_SHELL_INTEGRATION === '1') {
1413-
process.stderr.write(`${processingMsg}\n`)
1414-
if (process.stderr.isTTY) {
1415-
fs.writeSync(process.stderr.fd, '')
1416-
}
1417-
}
1418-
else {
1419-
process.stdout.write(`${processingMsg}\n`)
1420-
}
1421-
1422-
// Brief delay to make the message visible
1423-
await new Promise(resolve => setTimeout(resolve, 100))
1424-
1425-
// Clear the processing message by moving cursor up and clearing the line
1426-
if (process.env.LAUNCHPAD_SHELL_INTEGRATION === '1') {
1427-
process.stderr.write('\x1B[1A\r\x1B[K')
1428-
if (process.stderr.isTTY) {
1429-
try {
1430-
fs.writeSync(process.stderr.fd, '')
1431-
}
1432-
catch {
1433-
// Ignore flush errors
1434-
}
1435-
}
1436-
}
1437-
else {
1438-
process.stdout.write('\x1B[1A\r\x1B[K')
1439-
}
1440-
}
1441-
1421+
// For cached packages, show completion message directly without intermediate processing message
14421422
logUniqueMessage(`✅ ${domain} \x1B[2m\x1B[3m(v${version})\x1B[0m`)
1423+
showedSuccessMessage = true
14431424
}
14441425

14451426
// Copy cached file to temp directory
@@ -1671,8 +1652,9 @@ export async function downloadPackage(
16711652
}
16721653
else {
16731654
// Only show extraction for very large packages (>20MB) to keep output clean
1655+
// But don't show if we already showed a success message (for cached packages)
16741656
const archiveStats = fs.statSync(archiveFile)
1675-
if (archiveStats.size > 20 * 1024 * 1024) {
1657+
if (archiveStats.size > 20 * 1024 * 1024 && !showedSuccessMessage) {
16761658
// Clear any existing spinner before starting extraction
16771659
if (hasTemporaryProcessingMessage) {
16781660
cleanupSpinner()
@@ -1778,7 +1760,7 @@ export async function downloadPackage(
17781760
else {
17791761
// Clear the extraction progress message if we showed one
17801762
const archiveStats = fs.statSync(archiveFile)
1781-
if (archiveStats.size > 20 * 1024 * 1024) {
1763+
if (archiveStats.size > 20 * 1024 * 1024 && !showedSuccessMessage) {
17821764
if (process.env.LAUNCHPAD_SHELL_INTEGRATION === '1') {
17831765
process.stderr.write('\x1B[1A\r\x1B[K')
17841766
if (process.stderr.isTTY) {
@@ -2861,6 +2843,9 @@ export async function install(packages: PackageSpec | PackageSpec[], basePath?:
28612843
}
28622844
}
28632845

2846+
// Clean up any lingering processing messages
2847+
cleanupAllProcessingMessages()
2848+
28642849
return allInstalledFiles
28652850
}
28662851

packages/launchpad/test/download-progress.test.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -513,31 +513,6 @@ describe('Download Progress', () => {
513513
})
514514

515515
describe('Cache vs Download Progress', () => {
516-
it('should show cache loading messages for cached packages', async () => {
517-
// Mock cache hit
518-
jest.spyOn(fs, 'existsSync').mockReturnValue(true)
519-
jest.spyOn(fs, 'statSync').mockReturnValue({ size: 1024 } as any)
520-
jest.spyOn(fs, 'copyFileSync').mockImplementation(jest.fn())
521-
522-
process.env.NODE_ENV = 'development'
523-
524-
const { downloadPackage } = await import('../src/install')
525-
526-
try {
527-
await downloadPackage('test.domain', '1.0.0', 'darwin', 'x86_64', tempDir)
528-
}
529-
catch {
530-
// Expected to fail due to mocking
531-
}
532-
533-
// Verify cache loading messages were written
534-
const cacheCalls = mockStdout.mock.calls.filter(call =>
535-
call[0].includes('🔄') && call[0].includes('Loading') && call[0].includes('cache'),
536-
)
537-
538-
expect(cacheCalls.length).toBeGreaterThan(0)
539-
})
540-
541516
it('should not show download progress for cached packages', async () => {
542517
// Mock cache hit
543518
jest.spyOn(fs, 'existsSync').mockReturnValue(true)

0 commit comments

Comments
 (0)