Skip to content

Commit 01df685

Browse files
committed
chore: wip
1 parent 7049ab1 commit 01df685

File tree

3 files changed

+121
-13
lines changed

3 files changed

+121
-13
lines changed

packages/launchpad/bin/cli.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,24 @@ const cli = new CAC('launchpad')
879879
cli.version(version)
880880
cli.help()
881881

882+
// Config command - show resolved user configuration
883+
cli
884+
.command('config', 'Show current Launchpad configuration')
885+
.option('--json', 'Output as JSON (default)')
886+
.example('launchpad config')
887+
.example('launchpad config --json')
888+
.action(async (_options?: { json?: boolean }) => {
889+
try {
890+
// Always output JSON for reliability (machine-readable)
891+
const output = JSON.stringify(config, null, 2)
892+
console.log(output)
893+
}
894+
catch (error) {
895+
console.error('Failed to load configuration:', error instanceof Error ? error.message : String(error))
896+
process.exit(1)
897+
}
898+
})
899+
882900
// Main installation command
883901
cli
884902
.command('install [packages...]', 'Install packages or set up development environment')

packages/launchpad/src/binary-downloader.ts

Lines changed: 102 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import * as fs from 'node:fs'
66
import * as path from 'node:path'
77
import process from 'node:process'
88
import { config } from './config'
9+
import { createShims } from './install-helpers'
10+
import { logUniqueMessage } from './logging'
911

1012
export interface BinaryInfo {
1113
filename: string
@@ -509,17 +511,51 @@ Thanks for helping us make Launchpad better! 🙏
509511
const progressPercent = Math.floor(progress / 5) * 5 // Round to nearest 5%
510512

511513
if (now - lastProgressUpdate > 100 || progress >= 100 || downloadedBytes === value.length) {
512-
if (config.verbose) {
513-
const progressMsg = `⬇️ ${downloadedBytes}/${totalBytes} bytes (${progressPercent}%) - PHP ${binary.php_version}`
514+
const progressMsg = config.verbose
515+
? `⬇️ ${downloadedBytes}/${totalBytes} bytes (${progressPercent}%) - php.net v${binary.php_version}`
516+
: `⬇️ ${downloadedBytes}/${totalBytes} bytes (${progressPercent}%)`
517+
518+
if (process.env.LAUNCHPAD_SHELL_INTEGRATION === '1') {
519+
process.stderr.write(`\r${progressMsg}`)
520+
if (process.stderr.isTTY) {
521+
try {
522+
fs.writeSync(process.stderr.fd, '')
523+
}
524+
catch { /* ignore */ }
525+
}
526+
}
527+
else {
514528
process.stdout.write(`\r${progressMsg}`)
529+
if (process.stdout.isTTY) {
530+
try {
531+
fs.writeSync(process.stdout.fd, '')
532+
}
533+
catch { /* ignore */ }
534+
}
515535
}
516536
lastProgressUpdate = now
517537
}
518538
}
519539
}
520540

521-
if (config.verbose) {
522-
process.stdout.write('\r\x1B[K') // Clear the progress line
541+
// Clear the progress line
542+
if (process.env.LAUNCHPAD_SHELL_INTEGRATION === '1') {
543+
process.stderr.write('\r\x1B[K')
544+
if (process.stderr.isTTY) {
545+
try {
546+
fs.writeSync(process.stderr.fd, '')
547+
}
548+
catch { /* ignore */ }
549+
}
550+
}
551+
else {
552+
process.stdout.write('\r\x1B[K')
553+
if (process.stdout.isTTY) {
554+
try {
555+
fs.writeSync(process.stdout.fd, '')
556+
}
557+
catch { /* ignore */ }
558+
}
523559
}
524560

525561
// Combine all chunks
@@ -534,9 +570,52 @@ Thanks for helping us make Launchpad better! 🙏
534570
await fs.promises.writeFile(cachedPath, buffer)
535571
}
536572
else {
537-
// Fallback for unknown content length
573+
// Fallback for unknown content length - show simple download indicator
574+
const downloadMsg = config.verbose
575+
? `⬇️ Downloading php.net v${binary.php_version} (size unknown)...`
576+
: `⬇️ Downloading php.net v${binary.php_version}...`
577+
578+
if (process.env.LAUNCHPAD_SHELL_INTEGRATION === '1') {
579+
process.stderr.write(`\r${downloadMsg}`)
580+
if (process.stderr.isTTY) {
581+
try {
582+
fs.writeSync(process.stderr.fd, '')
583+
}
584+
catch { /* ignore */ }
585+
}
586+
}
587+
else {
588+
process.stdout.write(`\r${downloadMsg}`)
589+
if (process.stdout.isTTY) {
590+
try {
591+
fs.writeSync(process.stdout.fd, '')
592+
}
593+
catch { /* ignore */ }
594+
}
595+
}
596+
538597
const buffer = await response.arrayBuffer()
539598
await fs.promises.writeFile(cachedPath, Buffer.from(buffer))
599+
600+
// Clear the download message
601+
if (process.env.LAUNCHPAD_SHELL_INTEGRATION === '1') {
602+
process.stderr.write('\r\x1B[K')
603+
if (process.stderr.isTTY) {
604+
try {
605+
fs.writeSync(process.stderr.fd, '')
606+
}
607+
catch { /* ignore */ }
608+
}
609+
}
610+
else {
611+
process.stdout.write('\r\x1B[K')
612+
if (process.stdout.isTTY) {
613+
try {
614+
fs.writeSync(process.stdout.fd, '')
615+
}
616+
catch { /* ignore */ }
617+
}
618+
}
540619
}
541620

542621
if (config.verbose) {
@@ -1027,15 +1106,26 @@ export async function downloadPhpBinary(installPath: string, requestedVersion?:
10271106
throw new Error(`Failed to install PHP binary: ${result.error}`)
10281107
}
10291108

1030-
// Show clean success message (non-verbose) or detailed info (verbose)
1031-
if (config.verbose) {
1032-
console.log(`🎉 PHP ${result.version} (${result.configuration}) installed successfully!`)
1033-
console.log(`📁 Location: ${result.packageDir}`)
1034-
console.log(`🔌 Extensions: ${result.extensions.length} loaded`)
1109+
// Create shims in installPath/bin and sbin so php is available on PATH
1110+
try {
1111+
const installedBinaries = await createShims(result.packageDir, installPath, 'php.net', result.version)
1112+
// Optionally report number of binaries installed in verbose
1113+
if (config.verbose) {
1114+
console.log(`🎉 Successfully installed php.net (${installedBinaries.length} ${installedBinaries.length === 1 ? 'binary' : 'binaries'})`)
1115+
console.log(`📁 Location: ${result.packageDir}`)
1116+
console.log(`🔌 Extensions: ${result.extensions.length} loaded`)
1117+
}
10351118
}
1036-
else {
1037-
console.log(`✅ php.net (v${result.version})`)
1119+
catch (error) {
1120+
// Don't fail installation if shim creation has issues, but report in verbose
1121+
if (config.verbose) {
1122+
console.warn(`⚠️ Failed to create php shims: ${error instanceof Error ? error.message : String(error)}`)
1123+
}
10381124
}
10391125

1126+
// Show standardized success message
1127+
logUniqueMessage(`✅ php.net \x1B[2m\x1B[3m(v${result.version})\x1B[0m`)
1128+
1129+
// Keep return shape for compatibility
10401130
return [result.packageDir]
10411131
}

packages/launchpad/src/dev-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export async function setupPHPDevelopmentEnvironment(options?: {
191191
}
192192

193193
// Determine best database setup based on available extensions and user preferences
194-
const preferredDb = options?.preferredDatabase || config.services?.frameworks?.preferredDatabase || 'sqlite'
194+
const preferredDb = options?.preferredDatabase || 'sqlite'
195195
const forceSQLite = process.env.LAUNCHPAD_FORCE_SQLITE === 'true'
196196

197197
if (forceSQLite || preferredDb === 'sqlite') {

0 commit comments

Comments
 (0)