Skip to content

Commit e00a816

Browse files
committed
chore: wip
1 parent f0ddb6a commit e00a816

File tree

9 files changed

+731
-39
lines changed

9 files changed

+731
-39
lines changed

packages/launchpad/launchpad.config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ export const defaultConfig: LaunchpadConfig = {
6464
password: 'password',
6565
authMethod: 'trust',
6666
},
67-
php: {
68-
enabled: true,
69-
version: '8.4.11',
70-
},
7167
},
7268
}
7369

packages/launchpad/src/commands/install.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,20 +386,18 @@ async function installGlobalDependencies(options: { dryRun?: boolean, quiet?: bo
386386
// Check for excluded dependencies configuration
387387
const excludedDeps = (config as any).excludeDependencies || []
388388
const globalExcludedDeps = (config as any).excludeGlobalDependencies || []
389-
const phpExcludedDeps = (config.services?.php as any)?.excludeDependencies || []
390389

391390
const allExcludedDeps = new Set([
392391
...excludedDeps,
393392
...globalExcludedDeps,
394-
...phpExcludedDeps,
395393
])
396394

397395
// Always install PHP dependencies by default - they are runtime dependencies, not build dependencies
398396
// Only exclude if explicitly configured to do so
399397
if (allExcludedDeps.size > 0) {
400398
try {
401-
const { pantry } = await import('ts-pkgx')
402-
const phpPackage = (pantry as any)?.phpnet
399+
const { packages } = await import('ts-pkgx')
400+
const phpPackage = (packages as any)?.phpnet
403401
const phpDeps: string[] = (phpPackage?.dependencies || []).map((dep: any) => {
404402
let name = ''
405403
if (typeof dep === 'string')

packages/launchpad/src/config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { homedir } from 'node:os'
44
import path from 'node:path'
55
import process from 'node:process'
66
import { loadConfig } from 'bunfig'
7-
8-
// Apply profile and validation
97
import { getEffectiveConfig, validateConfig } from './config-validation'
108

119
function getDefaultInstallPath(): string {
@@ -179,12 +177,7 @@ export const defaultConfig: LaunchpadConfig = {
179177
},
180178
frameworks: {
181179
enabled: process.env.LAUNCHPAD_FRAMEWORKS_ENABLED !== 'false',
182-
laravel: {
183-
enabled: process.env.LAUNCHPAD_LARAVEL_ENABLED !== 'false',
184-
autoDetect: process.env.LAUNCHPAD_LARAVEL_AUTO_DETECT !== 'false',
185-
},
186180
stacks: {
187-
enabled: process.env.LAUNCHPAD_STACKS_ENABLED !== 'false',
188181
autoDetect: process.env.LAUNCHPAD_STACKS_AUTO_DETECT !== 'false',
189182
},
190183
},
@@ -195,6 +188,7 @@ export const defaultConfig: LaunchpadConfig = {
195188
// eslint-disable-next-line antfu/no-top-level-await
196189
const rawConfig = await loadConfig({
197190
name: 'launchpad',
191+
alias: 'deps',
198192
defaultConfig,
199193
})
200194

packages/launchpad/src/dev-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export function getSupportedFrameworks(): ProjectFramework[] {
111111
})
112112
}
113113

114-
if (frameworksConfig.laravel?.enabled) {
114+
if ((frameworksConfig as any).laravel?.enabled) {
115115
frameworks.push({
116116
name: 'Laravel',
117117
detectionFile: 'artisan',

packages/launchpad/src/dev/sniff.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,15 +893,14 @@ function shouldInferServices(): boolean {
893893
// LAUNCHPAD_FRAMEWORKS_ENABLED and LAUNCHPAD_SERVICES_INFER
894894
const frameworksEnabled = process.env.LAUNCHPAD_FRAMEWORKS_ENABLED !== 'false'
895895
const inferServices = process.env.LAUNCHPAD_SERVICES_INFER !== 'false'
896-
const laravelEnabled = process.env.LAUNCHPAD_LARAVEL_ENABLED !== 'false'
897896
const stacksEnabled = process.env.LAUNCHPAD_STACKS_ENABLED !== 'false'
898897

899898
// Skip inference in shell integration mode for performance
900899
if (process.env.LAUNCHPAD_SHELL_INTEGRATION === '1') {
901900
return false
902901
}
903902

904-
return frameworksEnabled && inferServices && (laravelEnabled || stacksEnabled)
903+
return frameworksEnabled && inferServices && stacksEnabled
905904
}
906905

907906
async function inferServicesFromFramework(projectDir: string): Promise<{ autoStart: string[] }> {

packages/launchpad/src/install.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { downloadPackage } from './install-core'
44
import { install } from './install-main'
55
import { cleanupSpinner, resetInstalledTracker } from './logging'
66
import { getAllPackageAliases, getAllPackageDomains, getAllPackageNames, getAvailableVersions, getLatestVersion, getPackageInfo, isPackageAlias, isPackageDomain, isValidPackageName, isVersionAvailable, listAvailablePackages, parsePackageSpec, resolvePackageName, resolveVersion } from './package-resolution'
7-
import { buildSqliteFromSource, installDependenciesOnly, testPhpBinary } from './special-installers'
7+
import { buildSqliteFromSource, installDependenciesOnly } from './special-installers'
88
import { DISTRIBUTION_CONFIG } from './types'
99
import { install_prefix } from './utils'
1010

@@ -35,5 +35,4 @@ export {
3535
resolveAllDependencies,
3636
resolvePackageName,
3737
resolveVersion,
38-
testPhpBinary,
3938
}

packages/launchpad/src/special-installers.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,30 +247,30 @@ export async function installDependenciesOnly(packages: string[], installPath?:
247247
let totalDepsAlreadyInstalled = 0
248248

249249
try {
250-
// Import pantry from ts-pkgx to get package dependencies
251-
const { pantry } = await import('ts-pkgx')
250+
// Import packages from ts-pkgx to get package dependencies
251+
const { packages: pkgxPackages } = await import('ts-pkgx')
252252

253253
for (const packageName of packages) {
254254
// Resolve package name to domain
255255
const domain = resolvePackageName(packageName)
256256

257-
// Try different ways to find the package in pantry
257+
// Try different ways to find the package in packages
258258
let packageKey: string | undefined
259259

260260
// First, try exact matches
261-
packageKey = Object.keys(pantry).find(key => key === domain || key === packageName)
261+
packageKey = Object.keys(pkgxPackages).find(key => key === domain || key === packageName)
262262

263263
// Fallback to partial matches only if no exact match found
264264
if (!packageKey) {
265-
packageKey = Object.keys(pantry).find(key =>
265+
packageKey = Object.keys(pkgxPackages).find(key =>
266266
key.includes(packageName) || key.includes(domain.split('.')[0]),
267267
)
268268
}
269269

270-
const packageSpec = packageKey ? pantry[packageKey as keyof typeof pantry] : null
270+
const packageSpec = packageKey ? pkgxPackages[packageKey as keyof typeof pkgxPackages] : null
271271

272272
if (!packageSpec || !packageSpec.dependencies) {
273-
console.warn(`⚠️ Package ${packageName} not found in pantry or has no dependencies`)
273+
console.warn(`⚠️ Package ${packageName} not found in pkgxPackages or has no dependencies`)
274274
continue
275275
}
276276

packages/launchpad/src/types.ts

Lines changed: 101 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,95 @@
1-
import type { aliases, packages } from 'ts-pkgx'
1+
import type {
2+
PackageAlias,
3+
PackageDomain,
4+
PackageName,
5+
Packages,
6+
Dependencies
7+
} from 'ts-pkgx'
8+
import { createDependencies } from 'ts-pkgx'
29

3-
// Extract all package alias names from ts-pkgx
4-
export type PackageAlias = keyof typeof aliases
10+
// Re-export ts-pkgx types for internal use
11+
export type {
12+
PackageAlias,
13+
PackageDomain,
14+
PackageName,
15+
Packages,
16+
Dependencies
17+
}
18+
19+
// Re-export ts-pkgx utilities
20+
export { createDependencies }
521

6-
// Extract all package domain names from ts-pkgx packages
7-
export type PackageDomain = keyof typeof packages
22+
/**
23+
* Helper function to create a fully typed dependencies configuration with version validation
24+
* This provides IntelliSense and type safety for both package names AND versions!
25+
*/
26+
export function defineFullyTypedDependencies(deps: FullyTypedDependencies): FullyTypedDependencies {
27+
return deps
28+
}
829

9-
// Union type of all valid package identifiers (aliases + domains)
10-
export type PackageName = PackageAlias | PackageDomain
30+
31+
/**
32+
* Helper function to create a typed dependencies configuration (backward compatible)
33+
* This provides IntelliSense and type safety while maintaining flexibility
34+
*/
35+
export function definePackageDependencies(deps: TypedDependencies): TypedDependencies {
36+
return deps
37+
}
38+
39+
/**
40+
* Helper function to create a fully typed dependencies array
41+
*/
42+
export function definePackageList<T extends readonly PackageName[]>(packages: T): T {
43+
return packages
44+
}
1145

1246
// Type for package with optional version (allowing string for flexibility)
1347
export type PackageSpec = string
1448

49+
// Type for package dependency specification in config
50+
export interface PackageDependencySpec {
51+
version?: string
52+
global?: boolean
53+
}
54+
55+
// Extract version types from ts-pkgx packages
56+
type PackageVersions<T extends PackageName> = T extends keyof Packages
57+
? Packages[T] extends { versions: readonly (infer V)[] }
58+
? V extends string
59+
? V
60+
: never
61+
: never
62+
: never
63+
64+
// Version constraint that allows valid versions or version ranges
65+
type VersionConstraint<T extends PackageName> =
66+
| PackageVersions<T>
67+
| `^${PackageVersions<T>}`
68+
| `~${PackageVersions<T>}`
69+
| `>=${PackageVersions<T>}`
70+
| `<=${PackageVersions<T>}`
71+
| `>${PackageVersions<T>}`
72+
| `<${PackageVersions<T>}`
73+
| 'latest'
74+
| '*'
75+
76+
// Enhanced dependency spec with typed versions
77+
export interface TypedPackageDependencySpec<T extends PackageName> {
78+
version?: VersionConstraint<T>
79+
global?: boolean
80+
}
81+
82+
// Fully typed dependencies with version validation
83+
// Note: TypeScript will highlight property names for invalid versions (language limitation)
84+
export type FullyTypedDependencies = {
85+
readonly [K in PackageName]?: VersionConstraint<K> | TypedPackageDependencySpec<K>
86+
}
87+
88+
// Backward compatible typed dependencies (allows string versions for flexibility)
89+
export type TypedDependencies = {
90+
[K in PackageName]?: string | PackageDependencySpec
91+
}
92+
1593
// Supported distribution formats
1694
export type SupportedFormat = 'tar.xz' | 'tar.gz'
1795
export type SupportedPlatform = 'darwin' | 'linux' | 'windows'
@@ -65,6 +143,21 @@ export interface LaunchpadConfig {
65143
* - string | string[]: install only for the listed package name(s)
66144
*/
67145
installBuildDeps?: boolean | string | string[]
146+
/**
147+
* Package dependencies to install (similar to deps.yaml)
148+
* FULLY TYPED package names AND versions from ts-pkgx
149+
*
150+
* Supports both domain names ('bun.sh') and aliases ('bun')
151+
* Invalid package names and versions will cause TypeScript errors
152+
*
153+
* Use createDependencies() helper for enhanced developer experience:
154+
* dependencies: createDependencies({ 'bun': '^1.2.19' })
155+
*/
156+
dependencies?: Dependencies
157+
/**
158+
* Global flag for dependencies - when true, all dependencies are installed globally
159+
*/
160+
global?: boolean
68161
shellMessages?: {
69162
activation?: string
70163
deactivation?: string
@@ -209,7 +302,7 @@ export interface LaunchpadConfig {
209302
autoRestart?: boolean
210303
startupTimeout?: number
211304
shutdownTimeout?: number
212-
/** Infer services to auto-start from framework config (e.g., Laravel/Stacks .env) */
305+
/** Infer services to auto-start from framework config (e.g., Stacks .env) */
213306
infer?: boolean
214307
database?: {
215308
username?: string
@@ -218,10 +311,6 @@ export interface LaunchpadConfig {
218311
}
219312
frameworks?: {
220313
enabled?: boolean
221-
laravel?: {
222-
enabled?: boolean
223-
autoDetect?: boolean
224-
}
225314
stacks?: {
226315
enabled?: boolean
227316
autoDetect?: boolean

0 commit comments

Comments
 (0)