Skip to content

Commit 5527858

Browse files
committed
chore: wip
1 parent f6c39da commit 5527858

20 files changed

+871
-558
lines changed

packages/launchpad/bin/cli.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3175,13 +3175,13 @@ cli
31753175

31763176
if (format === 'json') {
31773177
const result = services.map(service => ({
3178-
name: service.definition.name,
3179-
displayName: service.definition.displayName,
3178+
name: service.definition?.name,
3179+
displayName: service.definition?.displayName,
31803180
status: service.status,
31813181
enabled: service.enabled,
31823182
pid: service.pid,
31833183
startedAt: service.startedAt,
3184-
port: service.definition.port,
3184+
port: service.definition?.port,
31853185
}))
31863186
console.log(JSON.stringify(result, null, 2))
31873187
}
@@ -3200,7 +3200,7 @@ cli
32003200
unknown: '⚪',
32013201
}[service.status]
32023202

3203-
console.log(`${statusEmoji} ${service.definition.name}: ${service.status}`)
3203+
console.log(`${statusEmoji} ${service.definition?.name}: ${service.status}`)
32043204
})
32053205
}
32063206
}
@@ -3212,7 +3212,7 @@ cli
32123212
console.log('Available services:')
32133213
const definitions = getAllServiceDefinitions()
32143214
definitions.forEach((def) => {
3215-
console.log(` ${def.name.padEnd(12)} ${def.displayName}`)
3215+
console.log(` ${def.name?.padEnd(12)} ${def.displayName}`)
32163216
})
32173217
}
32183218
else {
@@ -3231,12 +3231,12 @@ cli
32313231
unknown: '⚪',
32323232
}[service.status]
32333233

3234-
const name = service.definition.name.padEnd(12)
3234+
const name = service.definition?.name?.padEnd(12) || 'unknown'.padEnd(12)
32353235
const status = `${statusEmoji} ${service.status}`.padEnd(12)
32363236
const enabled = (service.enabled ? '✅' : '❌').padEnd(10)
32373237
const pid = (service.pid ? String(service.pid) : '-').padEnd(8)
3238-
const port = (service.definition.port ? String(service.definition.port) : '-').padEnd(8)
3239-
const description = service.definition.description
3238+
const port = (service.definition?.port ? String(service.definition.port) : '-').padEnd(8)
3239+
const description = service.definition?.description || ''
32403240

32413241
console.log(`${name}${status}${enabled}${pid}${port}${description}`)
32423242
})
@@ -3271,13 +3271,13 @@ cli
32713271

32723272
if (format === 'json') {
32733273
const result = services.map(service => ({
3274-
name: service.definition.name,
3275-
displayName: service.definition.displayName,
3274+
name: service.definition?.name,
3275+
displayName: service.definition?.displayName,
32763276
status: service.status,
32773277
enabled: service.enabled,
32783278
pid: service.pid,
32793279
startedAt: service.startedAt,
3280-
port: service.definition.port,
3280+
port: service.definition?.port,
32813281
}))
32823282
console.log(JSON.stringify(result, null, 2))
32833283
}
@@ -3296,7 +3296,7 @@ cli
32963296
unknown: '⚪',
32973297
}[service.status]
32983298

3299-
console.log(`${statusEmoji} ${service.definition.name}: ${service.status}`)
3299+
console.log(`${statusEmoji} ${service.definition?.name}: ${service.status}`)
33003300
})
33013301
}
33023302
}
@@ -3308,7 +3308,7 @@ cli
33083308
console.log('🔍 Available services:')
33093309
const definitions = getAllServiceDefinitions()
33103310
definitions.forEach((def) => {
3311-
console.log(` ${def.name.padEnd(12)} ${def.displayName} - ${def.description}`)
3311+
console.log(` ${def.name?.padEnd(12)} ${def.displayName} - ${def.description}`)
33123312
})
33133313
console.log('')
33143314
console.log('💡 Use "launchpad start <service>" to start a service')
@@ -3330,12 +3330,12 @@ cli
33303330
unknown: '⚪',
33313331
}[service.status]
33323332

3333-
const name = service.definition.name.padEnd(12)
3333+
const name = service.definition?.name?.padEnd(12) || 'unknown'.padEnd(12)
33343334
const status = `${statusEmoji} ${service.status}`.padEnd(12)
33353335
const enabled = (service.enabled ? '✅ Yes' : '❌ No').padEnd(12)
33363336
const pid = (service.pid ? String(service.pid) : '-').padEnd(8)
3337-
const port = (service.definition.port ? String(service.definition.port) : '-').padEnd(8)
3338-
const description = service.definition.description
3337+
const port = (service.definition?.port ? String(service.definition.port) : '-').padEnd(8)
3338+
const description = service.definition?.description || ''
33393339

33403340
console.log(`${name}${status}${enabled}${pid}${port}${description}`)
33413341
})

packages/launchpad/launchpad.config.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import type { LaunchpadConfig } from './src/types'
22

33
export const defaultConfig: LaunchpadConfig = {
4-
// Set to true for additional log information
4+
// Whether to show verbose output
55
verbose: false,
66

7-
// Path where binaries should be installed
8-
// Defaults to /usr/local if writable, otherwise ~/.local
9-
installationPath: '/usr/local',
10-
11-
// Installation path (alias for installationPath for backward compatibility)
7+
// Installation path for packages
128
installPath: '/usr/local',
139

1410
// Installation method - 'direct' for direct downloads, 'registry' for package registry

packages/launchpad/src/binary-downloader.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,20 @@ export class PrecompiledBinaryDownloader {
7272
* Check if user has customized PHP extensions that require source build
7373
*/
7474
private hasCustomExtensions(): { hasCustom: boolean, customExtensions: string[], reason: string } {
75-
const { extensions } = config.services.php
75+
const phpConfig = config.services?.php
76+
if (!phpConfig?.extensions) {
77+
return { hasCustom: false, customExtensions: [], reason: 'No PHP extensions configured' }
78+
}
79+
80+
const { extensions } = phpConfig
7681

7782
// Get all user-configured extensions
7883
const userExtensions = [
79-
...extensions.core,
80-
...extensions.database,
81-
...extensions.web,
82-
...extensions.utility,
83-
...extensions.optional,
84+
...(extensions.core || []),
85+
...(extensions.database || []),
86+
...(extensions.web || []),
87+
...(extensions.utility || []),
88+
...(extensions.optional || []),
8489
]
8590

8691
// Define what each precompiled config includes

packages/launchpad/src/config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ function getDefaultShimPath(): string {
3636

3737
export const defaultConfig: LaunchpadConfig = {
3838
verbose: process.env.LAUNCHPAD_VERBOSE === 'true' || false,
39-
installationPath: getDefaultInstallPath(),
4039
sudoPassword: process.env.SUDO_PASSWORD || '',
4140
devAware: true,
4241
autoSudo: process.env.LAUNCHPAD_AUTO_SUDO !== 'false',

packages/launchpad/src/dependency-resolution.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import process from 'node:process'
12
import { config } from './config'
2-
import { parsePackageSpec, resolvePackageName, getLatestVersion, resolveVersion, getPackageInfo } from './package-resolution'
3-
import { deduplicatePackagesByVersion } from './utils'
4-
import type { PackageSpec } from './types'
3+
import { installPackage } from './install-core'
4+
import { logUniqueMessage } from './logging'
5+
import { getAvailableVersions, getLatestVersion, getPackageInfo, parsePackageSpec, resolvePackageName, resolveVersion } from './package-resolution'
6+
import { deduplicatePackagesByVersion, getPlatform } from './utils'
57

68
// Global tracker for deduplicating packages across all install calls
79
const globalInstalledTracker = new Set<string>()
@@ -449,11 +451,6 @@ export async function installDependencies(
449451
return allInstalledFiles
450452
}
451453

452-
// Import these functions from other modules
453-
import { getPlatform } from './utils'
454-
import { logUniqueMessage } from './logging'
455-
import { installPackage } from './install-core'
456-
457454
// Global variables from logging module
458455
let hasTemporaryProcessingMessage = false
459456
let spinnerInterval: Timer | null = null

packages/launchpad/src/dev-setup.ts

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -91,32 +91,37 @@ export interface ProjectFramework {
9191
export function getSupportedFrameworks(): ProjectFramework[] {
9292
const frameworks: ProjectFramework[] = []
9393

94-
if (config.services.frameworks.enabled) {
95-
if (config.services.frameworks.stacks.enabled) {
96-
frameworks.push({
97-
name: 'Stacks.js',
98-
detectionFile: 'buddy',
99-
databaseConfig: {
100-
envFile: '.env',
101-
migrationCommand: ['buddy', 'migrate'],
102-
seedCommand: ['buddy', 'db:seed'],
103-
configClearCommand: ['buddy', 'config:clear'],
104-
},
105-
})
106-
}
94+
const servicesConfig = config.services
95+
if (!servicesConfig?.frameworks?.enabled) {
96+
return frameworks
97+
}
10798

108-
if (config.services.frameworks.laravel.enabled) {
109-
frameworks.push({
110-
name: 'Laravel',
111-
detectionFile: 'artisan',
112-
databaseConfig: {
113-
envFile: '.env',
114-
migrationCommand: ['php', 'artisan', 'migrate:fresh'],
115-
seedCommand: ['php', 'artisan', 'db:seed'],
116-
configClearCommand: ['php', 'artisan', 'config:clear'],
117-
},
118-
})
119-
}
99+
const frameworksConfig = servicesConfig.frameworks
100+
101+
if (frameworksConfig.stacks?.enabled) {
102+
frameworks.push({
103+
name: 'Stacks.js',
104+
detectionFile: 'buddy',
105+
databaseConfig: {
106+
envFile: '.env',
107+
migrationCommand: ['buddy', 'migrate'],
108+
seedCommand: ['buddy', 'db:seed'],
109+
configClearCommand: ['buddy', 'config:clear'],
110+
},
111+
})
112+
}
113+
114+
if (frameworksConfig.laravel?.enabled) {
115+
frameworks.push({
116+
name: 'Laravel',
117+
detectionFile: 'artisan',
118+
databaseConfig: {
119+
envFile: '.env',
120+
migrationCommand: ['php', 'artisan', 'migrate:fresh'],
121+
seedCommand: ['php', 'artisan', 'db:seed'],
122+
configClearCommand: ['php', 'artisan', 'config:clear'],
123+
},
124+
})
120125
}
121126

122127
return frameworks
@@ -186,7 +191,7 @@ export async function setupPHPDevelopmentEnvironment(options?: {
186191
}
187192

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

192197
if (forceSQLite || preferredDb === 'sqlite') {
@@ -287,8 +292,8 @@ async function setupPostgreSQLEnvironment(framework: ProjectFramework): Promise<
287292
DB_HOST: actualConfig?.host || '127.0.0.1',
288293
DB_PORT: String(actualConfig?.port || 5432),
289294
DB_DATABASE: actualConfig?.database || projectName,
290-
DB_USERNAME: actualConfig?.username || config.services.database.username,
291-
DB_PASSWORD: actualConfig?.password || config.services.database.password,
295+
DB_USERNAME: actualConfig?.username || config.services?.database?.username || 'root',
296+
DB_PASSWORD: actualConfig?.password || config.services?.database?.password || 'password',
292297
}
293298

294299
// Update environment for PostgreSQL (only update if not already configured)

packages/launchpad/src/dev/dump.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ export async function detectLaravelProject(dir: string): Promise<{ isLaravel: bo
200200
}
201201

202202
// Execute post-setup commands if enabled
203-
if (config.services.frameworks.laravel.postSetupCommands?.enabled) {
204-
const postSetupResults = await executePostSetupCommands(dir, config.services.frameworks.laravel.postSetupCommands.commands)
203+
const laravelConfig = config.services?.frameworks?.laravel
204+
if (laravelConfig?.postSetupCommands?.enabled) {
205+
const postSetupResults = await executePostSetupCommands(dir, laravelConfig.postSetupCommands.commands || [])
205206
suggestions.push(...postSetupResults)
206207
}
207208

0 commit comments

Comments
 (0)